mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
commit
00cefa75d9
@ -39,6 +39,7 @@ type QQClient struct {
|
||||
FriendList []*FriendInfo
|
||||
GroupList []*GroupInfo
|
||||
Online bool
|
||||
NetLooping bool
|
||||
|
||||
SequenceId int32
|
||||
OutGoingPacketSessionId []byte
|
||||
@ -950,9 +951,10 @@ func (c *QQClient) connect() error {
|
||||
}
|
||||
|
||||
func (c *QQClient) Disconnect() {
|
||||
if c.Online {
|
||||
c.NetLooping = false
|
||||
c.Online = false
|
||||
c.Conn.Close()
|
||||
if c.Conn != nil {
|
||||
_ = c.Conn.Close()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1037,10 +1039,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 c.Online {
|
||||
for c.NetLooping {
|
||||
l, err := reader.ReadInt32()
|
||||
if err == io.EOF || err == io.ErrClosedPipe {
|
||||
c.Error("connection dropped by server: %v", err)
|
||||
@ -1055,7 +1058,7 @@ func (c *QQClient) netLoop() {
|
||||
retry++
|
||||
time.Sleep(time.Second * 3)
|
||||
if retry > 10 {
|
||||
c.Online = false
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -1065,7 +1068,7 @@ func (c *QQClient) netLoop() {
|
||||
c.Error("parse incoming packet error: %v", err)
|
||||
errCount++
|
||||
if errCount > 5 {
|
||||
c.Online = false
|
||||
break
|
||||
}
|
||||
//log.Println("parse incoming packet error: " + err.Error())
|
||||
continue
|
||||
@ -1107,6 +1110,7 @@ func (c *QQClient) netLoop() {
|
||||
}
|
||||
}()
|
||||
}
|
||||
c.NetLooping = false
|
||||
c.Online = false
|
||||
_ = c.Conn.Close()
|
||||
if c.lastLostMsg == "" {
|
||||
|
@ -1020,19 +1020,17 @@ func decodeForceOfflinePacket(c *QQClient, _ uint16, payload []byte) (interface{
|
||||
data.ReadFrom(jce.NewJceReader(request.SBuffer))
|
||||
r := jce.NewJceReader(data.Map["req_PushForceOffline"]["PushNotifyPack.RequestPushForceOffline"][1:])
|
||||
tips := r.ReadString(2)
|
||||
if c.Online {
|
||||
c.lastLostMsg = tips
|
||||
c.NetLooping = false
|
||||
c.Online = false
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// StatSvc.ReqMSFOffline
|
||||
func decodeMSFOfflinePacket(c *QQClient, _ uint16, _ []byte) (interface{}, error) {
|
||||
if c.Online {
|
||||
c.lastLostMsg = "服务器端强制下线."
|
||||
c.NetLooping = false
|
||||
c.Online = false
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user