1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

use LoadAndDelete

This commit is contained in:
wdvxdr 2020-12-11 23:10:46 +08:00
parent c07a8a9c8a
commit 01c133ebec
3 changed files with 5 additions and 6 deletions

View File

@ -1016,13 +1016,11 @@ func (c *QQClient) netLoop() {
if err != nil {
c.Debug("decode pkt %v error: %+v", pkt.CommandName, err)
}
if f, ok := c.handlers.Load(pkt.SequenceId); ok {
c.handlers.Delete(pkt.SequenceId)
if f, ok := c.handlers.LoadAndDelete(pkt.SequenceId); ok {
f.(func(i interface{}, err error))(rsp, err)
}
} else if f, ok := c.handlers.Load(pkt.SequenceId); ok {
} else if f, ok := c.handlers.LoadAndDelete(pkt.SequenceId); ok {
// does not need decoder
c.handlers.Delete(pkt.SequenceId)
f.(func(i interface{}, err error))(nil, nil)
} else {
c.Debug("\nUnhandled Command: %s\nSeq: %d\nThis message can be ignored.", pkt.CommandName, pkt.SequenceId)

View File

@ -2,8 +2,9 @@ package client
import (
"fmt"
"github.com/Mrs4s/MiraiGo/client/pb/notify"
"strconv"
"github.com/Mrs4s/MiraiGo/client/pb/notify"
)
type (

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/Mrs4s/MiraiGo
go 1.14
go 1.15
require (
github.com/golang/protobuf v1.4.3