mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
fix netloop
This commit is contained in:
parent
b621166549
commit
9ec164400c
@ -39,6 +39,7 @@ type QQClient struct {
|
||||
FriendList []*FriendInfo
|
||||
GroupList []*GroupInfo
|
||||
Online bool
|
||||
NetLooping bool
|
||||
|
||||
SequenceId int32
|
||||
OutGoingPacketSessionId []byte
|
||||
@ -955,6 +956,7 @@ func (c *QQClient) connect() error {
|
||||
}
|
||||
|
||||
func (c *QQClient) Disconnect() {
|
||||
c.NetLooping = false
|
||||
c.Online = false
|
||||
if c.Conn != nil {
|
||||
_ = c.Conn.Close()
|
||||
@ -1042,10 +1044,11 @@ func (c *QQClient) sendAndWait(seq uint16, pkt []byte) (interface{}, error) {
|
||||
}
|
||||
|
||||
func (c *QQClient) netLoop() {
|
||||
c.NetLooping = true
|
||||
reader := binary.NewNetworkReader(c.Conn)
|
||||
retry := 0
|
||||
errCount := 0
|
||||
for {
|
||||
for c.NetLooping {
|
||||
l, err := reader.ReadInt32()
|
||||
if err == io.EOF || err == io.ErrClosedPipe {
|
||||
c.Error("connection dropped by server: %v", err)
|
||||
@ -1112,6 +1115,7 @@ func (c *QQClient) netLoop() {
|
||||
}
|
||||
}()
|
||||
}
|
||||
c.NetLooping = false
|
||||
c.Online = false
|
||||
_ = c.Conn.Close()
|
||||
if c.lastLostMsg == "" {
|
||||
|
@ -1021,6 +1021,7 @@ func decodeForceOfflinePacket(c *QQClient, _ uint16, payload []byte) (interface{
|
||||
r := jce.NewJceReader(data.Map["req_PushForceOffline"]["PushNotifyPack.RequestPushForceOffline"][1:])
|
||||
tips := r.ReadString(2)
|
||||
c.lastLostMsg = tips
|
||||
c.NetLooping = false
|
||||
c.Online = false
|
||||
return nil, nil
|
||||
}
|
||||
@ -1028,6 +1029,7 @@ func decodeForceOfflinePacket(c *QQClient, _ uint16, payload []byte) (interface{
|
||||
// StatSvc.ReqMSFOffline
|
||||
func decodeMSFOfflinePacket(c *QQClient, _ uint16, _ []byte) (interface{}, error) {
|
||||
c.lastLostMsg = "服务器端强制下线."
|
||||
c.NetLooping = false
|
||||
c.Online = false
|
||||
return nil, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user