Lu.Caption = strTheU
End Sub
Private Sub Ws_Close(Index As Integer)
Ws(Index).Close
用户(Index).用户状态 = 0
Call RemoteUser(CLng(Index))
DeBugs ("用户:"用户(Index).用户名"离开了游戏")
End Sub
Private Sub Ws_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim sData As String
Dim ClsData As New Data
If bytesTotal = 0 Then
MsgBox "收到的数据为空"
Ws(Index).Close: Exit Sub
End If
Ws(Index).GetData sData, vbString
DoEvents
Call ClsData.DataControl(sData, Index)
DeBugs ("收到包:"sData)
End Sub
Private Sub Ws_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
DeBugs (Err.Description)
End Sub
Private Sub WsListen_ConnectionRequest(ByVal requestID As Long)
Dim I As Long
'//首先按顺序接收请求.
For I = 当前连接号 To 最大人数
If Ws(I).State = 0 Then
Ws(I).Accept requestID
DeBugs ("接收到远程用户的连接请求("Ws(I).RemoteHostIP")")
当前连接号 = I
Exit For
End If
Next
'///如果按顺序没有空连接,则查看前面有没有退出的用户
If I = 最大人数 Then
For I = 1 To 当前连接号
If Ws(I).State = 0 Then
Ws(I).Accept requestID
Else
'WsBusy.Accept requestID
' If WsBusy.State = 7 Then
'WsBusy.SendData "服务已经满了...."
'WsBusy.Close
' End If
End If
Next
End If
End Sub
Sub DeBugs(Str)
txtDebug.Text = txtDebug.TextStrvbCrLf
End Sub
Public Function Login(Index As Integer, UserName As String, UserPass As String) As String
If UserName = "" Or UserPass = "" Then Login = Encrypt("999$用户名密码不能为空", "", "", "")
Dim strSql As String
Dim RsLogin As New ADODB.Recordset
strSql = "select sex,score,win,lose,groups,positions,pic,nick,lastlogintime from [user] where username='"UserName"' and userPass='"UserPass"'"
If RsLogin.State = 1 Then RsLogin.Close
RsLogin.Open strSql, Conn, 1, 3
If RsLogin.EOF Or RsLogin.BOF Then
Login = Encrypt("404$用户名或是密码错误", "", "", "")
Else
RsLogin("LastLoginTime") = Now
Dim K As Integer
Dim Plain() As String
'性别+积分+胜+输+团队+职务+头像+昵称
Ustr(Index) = ""
For K = 0 To RsLogin.Fields.Count - 1
Ustr(Index) = Ustr(Index)RsLogin(K)"$"
Next
Plain = Split("$"Ustr(Index), "$")
With 用户(Index)
.连接号 = Index
.用户名 = UserName
.密码 = UserPass
.用户状态 = 1
.头像 = Plain(7)
.胜 = Plain(3)
.败 = Plain(4)
.昵称 = Plain(8)
.团队名 = Plain(5)
.职务 = Plain(6)
.积分 = Plain(2)
.性别 = Plain(1)
.IP = Ws(Index).RemoteHostIP
End With
LsUser.AddItem UserName
用户(Index).在线列表号 = LsUser.ListCount - 1
LsUser.Refresh
Labonline.Caption = "共有"LsUser.ListCount"人在线"
Login = "20$"Ustr(Index)"$"用户(Index).连接号
End If
'If RsLogin.State = 1 Then RsLogin.Close
End Function
Public Sub KillUser(Index As Integer)
If Index0 Then Exit Sub
Ws(Index + 1).Close
用户(Index + 1).用户状态 = 0
Call RemoteUser(Index + 1)
End Sub
Public Sub RemoteUser(Index As Integer)
' On Error Resume Next
If Index = -1 Then Exit Sub
Dim I As Long
For I = 0 To LsUser.ListCount - 1
If Trim(LsUser.List(I)) = Trim(用户(Index).用户名) Then
LsUser.RemoveItem I
LsUser.Refresh
Labonline.Caption = "共有"LsUser.ListCount"人在线"
'Exit For
End If
Next
End Sub
推荐阅读
- linux配置时间命令,linux配置命令退出快捷
- linux命令还原,linux怎么还原文件
- 公司电脑怎么设置手机密码,单位电脑怎么设置密码
- 主播直播洗澡软件,前段时间直播洗脸的明星
- C语言带g的函数 c语言带g的函数怎么写
- 用什么程序好看视频,上好看视频的视频用什么软件剪辑好
- 旧版ppt怎么录屏,ppt2003录屏怎么录
- gis文本竖着,gis布局怎么横向视图
- 主要是练习怎么安装mysql 怎么安装mysql8023