项目事件
AfterOpenProject
Forms("启动服务器").Open()
Server_UserLogging
If e.User Is Nothing Then
Return
Else
e.Success = True
End If
Dim dr As DataRow
dr = DataTables("好友").Find("用户 = '" &
e.User.Name & "'")
If dr IsNot Nothing Then
Dim nms As New List(of String)
nms.AddRange(dr("好友").Split(","))
For Each u As UserInfo In Users
If u.Name <> e.User.Name Then
If nms.Contains(u.Name) OrElse nms.Contains("[" & u.Group
& "]")
If u.Group >
"" Then
e.Buddies.Add(u.Group &
"." & u.Name)
Else
e.Buddies.Add(u.Name)
End If
End If
End If
Next
Else
For Each u As UserInfo In Users
If u.Name <> e.User.Name
Then
If u.Group > "" Then
e.Buddies.Add(u.Group &
"." & u.Name)
Else
e.Buddies.Add(u.Name)
End If
End If
Next
End If
窗口与控件事件
启动服务器_Button1_Click
QQServer.Stop()
启动服务器_启动服务器_Click
QQServer.ServerIp =
e.Form.Controls("txtIP").Value '指定IP地址
QQServer.ServerPort =
e.Form.Controls("txtPort").Value '指定端口
QQServer.HeartbeatInterval =
e.Form.Controls("txtInterval").Value '指定心跳时间
QQServer.HeartbeatTimeout =
e.Form.Controls("txtTimeOut").Value '指定心跳超时时间
QQserver.Buildin = True '一定要加上这个,表示使用内置身份验证
QQServer.Start() '启动QQServer
客户端代码:
项目事件
AfterOpenProject
Forms("登录窗口").Open()
Client_ReceivedMessage
Dim dt As DataRow = DataTables("信息").AddNew
dt("发送者") = iif(e.UserName >
"",e.UserName,"服务器")
dt("时间") = Date.Now()
dt("信息") = e.Message
窗口与控件事件
登录窗口_AfterLoad
e.Form.Controls("btnChat").Enabled
= QQClient.Ready
登录窗口_btnChat_Click
If
QQClient.Ready Then
QQClient.OpenChatWindow()
End If
登录窗口_Button1_Click
If QQClient.Ready Then
MessageBox.show("QQClient已经启动,请先关闭","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
QQClient.ServerIP =
e.Form.Controls("txtIP").Value
'指定服务器IP地址
QQClient.ServerPort =
e.Form.Controls("txtPort").Value
'指定服务器端口
QQClient.UserName =""
QQClient.Password = ""
If QQClient.Start() = True '如果登录成功
e.Form.Controls("btnChat").Enabled = True
Dim msg As String = "恭喜,OpenQQ登录成功!"
If QQClient.ServerMessage > "" Then '如果服务器返回了欢迎信息
msg = msg & QQClient.ServerMessage
End If
ConfigBar.Items("OpenQQ").SmallImage =
GetImage("online.ico")
popMessage(msg,"提示",PopiconEnum.Infomation,5)
Else '如果登录失败,显示服务器返回错误信息
e.Form.Controls("btnChat").Enabled
= False
PopMessage("QQClient登录失败,原因:" & vbcrlf & QQClient.ServerMessage,"提示",PopiconEnum.Error,5)
End If
登录窗口_Button2_Click
If QQClient.Ready = True Then
QQClient.Stop()
e.Form.Controls("btnChat").Enabled = False
End If