以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  【求助】OpenQQ 登录问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=196406)

--  作者:王小风
--  发布时间:2025/4/23 18:12:00
--  【求助】OpenQQ 登录问题
图片点击可在新窗口打开查看 按照模板文件搬过来的代码 也提示登录失败
服务器代码:QQServer.ServerIp = e.Form.Controls("TextBox1").Value \'指定IP地址
QQServer.ServerPort = e.Form.Controls("TextBox2").Value \'指定端口
QQServer.HeartbeatInterval = e.Form.Controls("TextBox3").Value \'指定心跳时间
QQServer.HeartbeatTimeout = e.Form.Controls("TextBox4").Value \'指定心跳超时时间
QQserver.Buildin = True \'一定要加上这个,表示使用内置身份验证
QQServer.Start() \'启动QQServer

登录代码:
If QQClient.Ready Then
    MessageBox.show("QQClient已经启动,请先关闭", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
    Return
End If
QQClient.ServerIP = e.Form.Controls("TextBox1").Value \'指定服务器IP地址
QQClient.ServerPort = e.Form.Controls("TextBox2").Value \'指定服务器端口
QQClient.UserName = ""
QQClient.Password = ""
If QQClient.Start() = True  Then\'如果登录成功
    e.Form.Controls("b-ltck").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("b-ltck").Enabled = False
    PopMessage("QQClient登录失败,原因:" & vbcrlf & QQClient.ServerMessage, "提示", PopiconEnum.Error, 5)
End If
网络监控代码:
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 & "]") Then
                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

--  作者:有点蓝
--  发布时间:2025/4/24 8:42:00
--  
单机测试,还是跨网络测试?ServerIp填的是什么地址?

不要使用开发者和管理员账户测试

--  作者:王小风
--  发布时间:2025/4/24 13:46:00
--  
单机本地测试 服务器地址127.0.0.1  端口52177
用普通用户打开服务,和登录都是一样的结果!


--  作者:有点蓝
--  发布时间:2025/4/24 13:51:00
--  
服务端UserLogging只保留下面代码测试有没有问题

网络监控代码:
If e.User Is Nothing Then
    Return
Else
    e.Success = True
End If

另外注意服务端和客户端需要分开2个项目