mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
fix bug.
This commit is contained in:
parent
ca4383f56a
commit
298c1bb911
@ -58,6 +58,7 @@ type QQClient struct {
|
|||||||
|
|
||||||
lastMessageSeq int32
|
lastMessageSeq int32
|
||||||
lastMessageSeqTmp sync.Map
|
lastMessageSeqTmp sync.Map
|
||||||
|
lastLostMsg string
|
||||||
groupMsgBuilders sync.Map
|
groupMsgBuilders sync.Map
|
||||||
onlinePushCache []int16 // reset on reconnect
|
onlinePushCache []int16 // reset on reconnect
|
||||||
requestPacketRequestId int32
|
requestPacketRequestId int32
|
||||||
@ -152,6 +153,7 @@ func (c *QQClient) Login() (*LoginResponse, error) {
|
|||||||
}
|
}
|
||||||
l := rsp.(LoginResponse)
|
l := rsp.(LoginResponse)
|
||||||
if l.Success {
|
if l.Success {
|
||||||
|
c.lastLostMsg = ""
|
||||||
c.registerClient()
|
c.registerClient()
|
||||||
go c.heartbeat()
|
go c.heartbeat()
|
||||||
_, _ = c.sendAndWait(c.buildGetMessageRequestPacket(msg.SyncFlag_START, time.Now().Unix()))
|
_, _ = c.sendAndWait(c.buildGetMessageRequestPacket(msg.SyncFlag_START, time.Now().Unix()))
|
||||||
@ -693,8 +695,6 @@ func (c *QQClient) loop() {
|
|||||||
if err == io.EOF || err == io.ErrClosedPipe {
|
if err == io.EOF || err == io.ErrClosedPipe {
|
||||||
err = c.connect()
|
err = c.connect()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Online = false
|
|
||||||
c.dispatchDisconnectEvent(&ClientDisconnectedEvent{Message: "Connection lost."})
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
reader = binary.NewNetworkReader(c.Conn)
|
reader = binary.NewNetworkReader(c.Conn)
|
||||||
@ -705,7 +705,6 @@ func (c *QQClient) loop() {
|
|||||||
time.Sleep(time.Second * 3)
|
time.Sleep(time.Second * 3)
|
||||||
if retry > 10 {
|
if retry > 10 {
|
||||||
c.Online = false
|
c.Online = false
|
||||||
c.dispatchDisconnectEvent(&ClientDisconnectedEvent{Message: "Connection lost."})
|
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -749,6 +748,10 @@ func (c *QQClient) loop() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
_ = c.Conn.Close()
|
_ = c.Conn.Close()
|
||||||
|
if c.lastLostMsg == "" {
|
||||||
|
c.lastLostMsg = "Connection lost."
|
||||||
|
}
|
||||||
|
c.dispatchDisconnectEvent(&ClientDisconnectedEvent{Message: c.lastLostMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) heartbeat() {
|
func (c *QQClient) heartbeat() {
|
||||||
|
@ -666,16 +666,16 @@ func decodeForceOfflinePacket(c *QQClient, _ uint16, payload []byte) (interface{
|
|||||||
r := jce.NewJceReader(data.Map["req_PushForceOffline"]["PushNotifyPack.RequestPushForceOffline"][1:])
|
r := jce.NewJceReader(data.Map["req_PushForceOffline"]["PushNotifyPack.RequestPushForceOffline"][1:])
|
||||||
tips := r.ReadString(2)
|
tips := r.ReadString(2)
|
||||||
if c.Online {
|
if c.Online {
|
||||||
|
c.lastLostMsg = tips
|
||||||
c.Online = false
|
c.Online = false
|
||||||
c.dispatchDisconnectEvent(&ClientDisconnectedEvent{Message: tips})
|
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeMSFOfflinePacket(c *QQClient, _ uint16, _ []byte) (interface{}, error) {
|
func decodeMSFOfflinePacket(c *QQClient, _ uint16, _ []byte) (interface{}, error) {
|
||||||
if c.Online {
|
if c.Online {
|
||||||
|
c.lastLostMsg = "服务器端强制下线."
|
||||||
c.Online = false
|
c.Online = false
|
||||||
c.dispatchDisconnectEvent(&ClientDisconnectedEvent{Message: "服务器端强制下线."})
|
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user