1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

fix online push.

This commit is contained in:
Mrs4s 2020-10-21 07:31:42 +08:00
parent 16b1d91e24
commit d0639731db
2 changed files with 5 additions and 12 deletions

View File

@ -76,7 +76,7 @@ type QQClient struct {
transCache *utils.Cache transCache *utils.Cache
lastLostMsg string lastLostMsg string
groupMsgBuilders sync.Map groupMsgBuilders sync.Map
onlinePushCache []int16 // reset on reconnect onlinePushCache *utils.Cache
requestPacketRequestId int32 requestPacketRequestId int32
groupSeq int32 groupSeq int32
friendSeq int32 friendSeq int32
@ -170,6 +170,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
eventHandlers: &eventHandlers{}, eventHandlers: &eventHandlers{},
msgSvcCache: utils.NewCache(time.Second * 15), msgSvcCache: utils.NewCache(time.Second * 15),
transCache: utils.NewCache(time.Second * 15), transCache: utils.NewCache(time.Second * 15),
onlinePushCache: utils.NewCache(time.Second * 15),
version: genVersionInfo(SystemDeviceInfo.Protocol), version: genVersionInfo(SystemDeviceInfo.Protocol),
servers: []*net.TCPAddr{ // default servers servers: []*net.TCPAddr{ // default servers
{IP: net.IP{42, 81, 169, 46}, Port: 8080}, {IP: net.IP{42, 81, 169, 46}, Port: 8080},
@ -946,7 +947,6 @@ func (c *QQClient) connect() error {
c.retryTimes = 0 c.retryTimes = 0
c.ConnectTime = time.Now() c.ConnectTime = time.Now()
c.Conn = conn c.Conn = conn
c.onlinePushCache = []int16{}
return nil return nil
} }

View File

@ -693,19 +693,12 @@ func decodeOnlinePushReqPacket(c *QQClient, seq uint16, payload []byte) (interfa
uin := jr.ReadInt64(0) uin := jr.ReadInt64(0)
jr.ReadSlice(&msgInfos, 2) jr.ReadSlice(&msgInfos, 2)
_ = c.send(c.buildDeleteOnlinePushPacket(uin, seq, msgInfos)) _ = c.send(c.buildDeleteOnlinePushPacket(uin, seq, msgInfos))
seqExists := func(ms int16) bool {
for _, s := range c.onlinePushCache {
if ms == s {
return true
}
}
return false
}
for _, m := range msgInfos { for _, m := range msgInfos {
if seqExists(m.MsgSeq) { k := fmt.Sprintf("%v%v%v", m.MsgSeq, m.MsgTime, m.MsgUid)
if _, ok := c.onlinePushCache.Get(k); ok {
continue continue
} }
c.onlinePushCache = append(c.onlinePushCache, m.MsgSeq) c.onlinePushCache.Add(k, "", time.Second*30)
if m.MsgType == 732 { if m.MsgType == 732 {
r := binary.NewReader(m.VMsg) r := binary.NewReader(m.VMsg)
groupId := int64(uint32(r.ReadInt32())) groupId := int64(uint32(r.ReadInt32()))