mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
optimize private msg decoder.
This commit is contained in:
parent
effa2b84fe
commit
a4fac7d635
@ -19,7 +19,11 @@ var c2cDecoders = map[int32]func(*QQClient, *msg.Message, *incomingPacketInfo){
|
|||||||
45: troopSystemMessageDecoder, 46: troopSystemMessageDecoder, 84: troopSystemMessageDecoder,
|
45: troopSystemMessageDecoder, 46: troopSystemMessageDecoder, 84: troopSystemMessageDecoder,
|
||||||
85: troopSystemMessageDecoder, 86: troopSystemMessageDecoder, 87: troopSystemMessageDecoder,
|
85: troopSystemMessageDecoder, 86: troopSystemMessageDecoder, 87: troopSystemMessageDecoder,
|
||||||
140: tempSessionDecoder, 141: tempSessionDecoder,
|
140: tempSessionDecoder, 141: tempSessionDecoder,
|
||||||
166: privateMessageDecoder, 208: privatePttDecoder,
|
9: privateMessageDecoder, 10: privateMessageDecoder, 31: privateMessageDecoder,
|
||||||
|
79: privateMessageDecoder, 97: privateMessageDecoder, 120: privateMessageDecoder,
|
||||||
|
132: privateMessageDecoder, 133: privateMessageDecoder, 166: privateMessageDecoder,
|
||||||
|
167: privateMessageDecoder,
|
||||||
|
208: privatePttDecoder,
|
||||||
187: systemMessageDecoder, 188: systemMessageDecoder, 189: systemMessageDecoder,
|
187: systemMessageDecoder, 188: systemMessageDecoder, 189: systemMessageDecoder,
|
||||||
190: systemMessageDecoder, 191: systemMessageDecoder,
|
190: systemMessageDecoder, 191: systemMessageDecoder,
|
||||||
529: msgType0x211Decoder,
|
529: msgType0x211Decoder,
|
||||||
@ -52,6 +56,7 @@ func (c *QQClient) c2cMessageSyncProcessor(rsp *msg.GetMessageResponse, info *in
|
|||||||
}
|
}
|
||||||
strKey := fmt.Sprintf("%d%d%d%d", pMsg.Head.GetFromUin(), pMsg.Head.GetToUin(), pMsg.Head.GetMsgSeq(), pMsg.Head.GetMsgUid())
|
strKey := fmt.Sprintf("%d%d%d%d", pMsg.Head.GetFromUin(), pMsg.Head.GetToUin(), pMsg.Head.GetMsgSeq(), pMsg.Head.GetMsgUid())
|
||||||
if _, ok := c.msgSvcCache.GetAndUpdate(strKey, time.Minute*5); ok {
|
if _, ok := c.msgSvcCache.GetAndUpdate(strKey, time.Minute*5); ok {
|
||||||
|
c.Debug("c2c msg %v already exists in cache. skip.", pMsg.Head.GetMsgUid())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.msgSvcCache.Add(strKey, "", time.Minute*5)
|
c.msgSvcCache.Add(strKey, "", time.Minute*5)
|
||||||
@ -60,6 +65,8 @@ func (c *QQClient) c2cMessageSyncProcessor(rsp *msg.GetMessageResponse, info *in
|
|||||||
}
|
}
|
||||||
if decoder, ok := c2cDecoders[pMsg.Head.GetMsgType()]; ok {
|
if decoder, ok := c2cDecoders[pMsg.Head.GetMsgType()]; ok {
|
||||||
decoder(c, pMsg, info)
|
decoder(c, pMsg, info)
|
||||||
|
} else {
|
||||||
|
c.Debug("unknown msg type on c2c processor: %v", pMsg.Head.GetMsgType())
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
switch pMsg.Head.GetMsgType() {
|
switch pMsg.Head.GetMsgType() {
|
||||||
@ -155,6 +162,8 @@ func (c *QQClient) c2cMessageSyncProcessor(rsp *msg.GetMessageResponse, info *in
|
|||||||
}
|
}
|
||||||
|
|
||||||
func privateMessageDecoder(c *QQClient, pMsg *msg.Message, _ *incomingPacketInfo) {
|
func privateMessageDecoder(c *QQClient, pMsg *msg.Message, _ *incomingPacketInfo) {
|
||||||
|
switch pMsg.Head.GetC2CCmd() {
|
||||||
|
case 11, 175: // friend msg
|
||||||
if pMsg.Head.GetFromUin() == c.Uin {
|
if pMsg.Head.GetFromUin() == c.Uin {
|
||||||
for {
|
for {
|
||||||
frdSeq := atomic.LoadInt32(&c.friendSeq)
|
frdSeq := atomic.LoadInt32(&c.friendSeq)
|
||||||
@ -171,6 +180,9 @@ func privateMessageDecoder(c *QQClient, pMsg *msg.Message, _ *incomingPacketInfo
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.dispatchFriendMessage(c.parsePrivateMessage(pMsg))
|
c.dispatchFriendMessage(c.parsePrivateMessage(pMsg))
|
||||||
|
default:
|
||||||
|
c.Debug("unknown c2c cmd on private msg decoder: %v", pMsg.Head.GetC2CCmd())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func privatePttDecoder(c *QQClient, pMsg *msg.Message, _ *incomingPacketInfo) {
|
func privatePttDecoder(c *QQClient, pMsg *msg.Message, _ *incomingPacketInfo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user