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
|
FriendList []*FriendInfo
|
||||||
GroupList []*GroupInfo
|
GroupList []*GroupInfo
|
||||||
Online bool
|
Online bool
|
||||||
|
NetLooping bool
|
||||||
|
|
||||||
SequenceId int32
|
SequenceId int32
|
||||||
OutGoingPacketSessionId []byte
|
OutGoingPacketSessionId []byte
|
||||||
@ -950,9 +951,10 @@ func (c *QQClient) connect() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) Disconnect() {
|
func (c *QQClient) Disconnect() {
|
||||||
if c.Online {
|
c.NetLooping = false
|
||||||
c.Online = 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() {
|
func (c *QQClient) netLoop() {
|
||||||
|
c.NetLooping = true
|
||||||
reader := binary.NewNetworkReader(c.Conn)
|
reader := binary.NewNetworkReader(c.Conn)
|
||||||
retry := 0
|
retry := 0
|
||||||
errCount := 0
|
errCount := 0
|
||||||
for c.Online {
|
for c.NetLooping {
|
||||||
l, err := reader.ReadInt32()
|
l, err := reader.ReadInt32()
|
||||||
if err == io.EOF || err == io.ErrClosedPipe {
|
if err == io.EOF || err == io.ErrClosedPipe {
|
||||||
c.Error("connection dropped by server: %v", err)
|
c.Error("connection dropped by server: %v", err)
|
||||||
@ -1055,7 +1058,7 @@ func (c *QQClient) netLoop() {
|
|||||||
retry++
|
retry++
|
||||||
time.Sleep(time.Second * 3)
|
time.Sleep(time.Second * 3)
|
||||||
if retry > 10 {
|
if retry > 10 {
|
||||||
c.Online = false
|
break
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -1065,7 +1068,7 @@ func (c *QQClient) netLoop() {
|
|||||||
c.Error("parse incoming packet error: %v", err)
|
c.Error("parse incoming packet error: %v", err)
|
||||||
errCount++
|
errCount++
|
||||||
if errCount > 5 {
|
if errCount > 5 {
|
||||||
c.Online = false
|
break
|
||||||
}
|
}
|
||||||
//log.Println("parse incoming packet error: " + err.Error())
|
//log.Println("parse incoming packet error: " + err.Error())
|
||||||
continue
|
continue
|
||||||
@ -1107,6 +1110,7 @@ func (c *QQClient) netLoop() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
c.NetLooping = false
|
||||||
c.Online = false
|
c.Online = false
|
||||||
_ = c.Conn.Close()
|
_ = c.Conn.Close()
|
||||||
if c.lastLostMsg == "" {
|
if c.lastLostMsg == "" {
|
||||||
|
@ -1020,19 +1020,17 @@ func decodeForceOfflinePacket(c *QQClient, _ uint16, payload []byte) (interface{
|
|||||||
data.ReadFrom(jce.NewJceReader(request.SBuffer))
|
data.ReadFrom(jce.NewJceReader(request.SBuffer))
|
||||||
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 {
|
c.lastLostMsg = tips
|
||||||
c.lastLostMsg = tips
|
c.NetLooping = false
|
||||||
c.Online = false
|
c.Online = false
|
||||||
}
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatSvc.ReqMSFOffline
|
// StatSvc.ReqMSFOffline
|
||||||
func decodeMSFOfflinePacket(c *QQClient, _ uint16, _ []byte) (interface{}, error) {
|
func decodeMSFOfflinePacket(c *QQClient, _ uint16, _ []byte) (interface{}, error) {
|
||||||
if c.Online {
|
c.lastLostMsg = "服务器端强制下线."
|
||||||
c.lastLostMsg = "服务器端强制下线."
|
c.NetLooping = false
|
||||||
c.Online = false
|
c.Online = false
|
||||||
}
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user