My Complete Code looks like this,
- $dir$bin\CuteChat.AppCode.dll
- $dir$bin\CuteChat.dll
- ==>END SYSTEMREFERENCE
- imports System.Collections
- imports CuteChat
- Public Class MyChatProvider
- inherits CuteChat.ChatProvider
- Dim pbw as New SiennEngine.pbw
- Dim Constring as string = pbw.get_constring()
- Dim Cid as string = pbw.get_cid_currentdomain()
-
- Dim prefix as string = Cid & "U_"
- Dim userId as string = pbw.get_customerId_Cookie(httpcontext.current.session)
- Public Overloads Overrides Function GetConnectionString() As String
- Dim Retstring as string = Constring
- Return Retstring
- End Function
- Public Overloads Overrides Function FindUserLoginName(ByVal nickName As String) As String
- Dim Retstring as string = ""
- Dim Query as string = "Select UserName from " & prefix & "users where Id = " & UserId
- Dim Con As New SqlConnection(constring)
-
- Dim Com As New SqlCommand(Query, Con)
- try
- Con.Open()
- Dim Reader As SqlDataReader = Com.ExecuteReader()
- while Reader.Read()
- Retstring=reader(0)
- End While
- catch
- end try
- Con.Close()
- Return Retstring
- End Function
- Public Overloads Overrides Function GetLogonIdentity() As AppChatIdentity
-
-
- Dim loginname As String = ""
- Dim nickname As String = ""
- Dim Query as string = "Select UserName, NickName from " & prefix & "users where Id = " & UserId
- Dim Con As New SqlConnection(constring)
-
- Dim Com As New SqlCommand(Query, Con)
- try
- Con.Open()
- Dim Reader As SqlDataReader = Com.ExecuteReader()
- while Reader.Read()
- loginname=reader(0)
- nickname =Reader(1)
- if Nickname is nothing or nickname = "" then nickname = loginname
- End While
- catch
- nickname = loginname
- end try
- Con.Close()
- Return New AppChatIdentity(nickname, False, ToUserId(loginname), HttpContext.Current.Request.UserHostAddress)
- End Function
- Public Overloads Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean
-
-
- Dim userType as integer =0
-
- Dim Query as string = "Select NickName,UserType from " & prefix & "users where username='" & loginName & "'"
- Dim Con As New SqlConnection(constring)
-
- Dim Com As New SqlCommand(Query, Con)
- try
- Con.Open()
- Dim Reader As SqlDataReader = Com.ExecuteReader()
- while Reader.Read()
- UserType=reader(1)
- nickname =Reader(0)
-
-
- if Nickname is nothing or nickname = "" then nickname = loginname
- End While
- catch
- nickname = loginname
- end try
- Con.Close()
- If UserType =1 then
- isAdmin = True
- else
- isAdmin = False
- end if
-
- Return true
- End Function
- Public Overloads Overrides Function ValidateUser(ByVal loginName As String, ByVal password As String) As Boolean
-
-
- return True
- End Function
- End Class
- ==>END IMPORTS
- CuteChat.ChatProvider.Instance = New MyChatProvider()
- try
- CuteChat.ChatSystem.Start(New CuteChat.AppSystem())
- catch
- end try
-
- Dim lobbies As New ArrayList()
- For Each Lobby as LobbyInfo In ChatApi.GetLobbyInfoArray()
- lobbies.Add(Lobby)
- Next
- if CuteChat.ChatWebUtility.CurrentIdentityIsAdministrator then
- Dim Hyperlink1 as new Hyperlink
- Hyperlink1.Id="Hyperlink1"
- Hyperlink1.NavigateUrl="/CuteSoft_Client/CuteChat/ChatAdmin/"
- Hyperlink1.text="Chat admin"
- Controlplace.controls.add(Hyperlink1)
- end if
-
- Controlplace.controls.add(New Literalcontrol("<br><script src=""/CuteSoft_Client/CuteChat/IntegrationUtility.js.aspx""></script>"))
- Controlplace.controls.add(New Literalcontrol("<br><img src=""/CuteSoft_Client/CuteChat/images/icon_invite.gif"" align=absmiddle>"))
- Controlplace.controls.add(New Literalcontrol("<a href=""###"" onclick=""BLOCKED SCRIPTChat_OpenMessenger()"">Messenger</a>"))
We have our own software to create visual basic source so te code is a little different then typing in visual studio.
The control I typed here is somewhere placed on the site.
There is as try/catch around"CuteChat.ChatSystem.Start(New CuteChat.AppSystem())" so I don't get an error. But the problem isn't solved, only one user at the time can chat. If I'm logging in with 2 users on different browsers(FF and IE) the second user get the message he already loged in. When I logoff the first user, the second user gets the name of the first one.
So I think only one chatsession at the time works.
I hope you can see something on my code