diff --git a/client/client.go b/client/client.go index 15678373..7dcbbee8 100644 --- a/client/client.go +++ b/client/client.go @@ -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 == "" { diff --git a/client/decoders.go b/client/decoders.go index 99061216..c9cf3dba 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -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 }