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

Merge pull request #77 from wdvxdr1123/sync.Map

use LoadAndDelete
This commit is contained in:
Mrs4s 2020-12-12 21:22:09 +08:00 committed by GitHub
commit 94779a6b76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 6 deletions

View File

@ -1016,13 +1016,11 @@ func (c *QQClient) netLoop() {
if err != nil { if err != nil {
c.Debug("decode pkt %v error: %+v", pkt.CommandName, err) c.Debug("decode pkt %v error: %+v", pkt.CommandName, err)
} }
if f, ok := c.handlers.Load(pkt.SequenceId); ok { if f, ok := c.handlers.LoadAndDelete(pkt.SequenceId); ok {
c.handlers.Delete(pkt.SequenceId)
f.(func(i interface{}, err error))(rsp, err) 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 // does not need decoder
c.handlers.Delete(pkt.SequenceId)
f.(func(i interface{}, err error))(nil, nil) f.(func(i interface{}, err error))(nil, nil)
} else { } else {
c.Debug("\nUnhandled Command: %s\nSeq: %d\nThis message can be ignored.", pkt.CommandName, pkt.SequenceId) 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 ( import (
"fmt" "fmt"
"github.com/Mrs4s/MiraiGo/client/pb/notify"
"strconv" "strconv"
"github.com/Mrs4s/MiraiGo/client/pb/notify"
) )
type ( type (

2
go.mod
View File

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