diff --git a/client/client.go b/client/client.go index baebb3a..cb69dfd 100644 --- a/client/client.go +++ b/client/client.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "net" + "reflect" "runtime" "sync" "sync/atomic" @@ -297,9 +298,11 @@ func (c *client) rpcReader(readerDone chan<- error) { func (c *client) responseHandle(codecResponse protocol.ClientCodecResponse) error { c.pendingRequestsLock.Lock() - cs, ok := c.pendingRequests[codecResponse.ID().(uint64)] + id := reflect.ValueOf(codecResponse.ID()).Convert(uint64Type).Uint() + + cs, ok := c.pendingRequests[id] if ok { - delete(c.pendingRequests, codecResponse.ID().(uint64)) + delete(c.pendingRequests, id) } c.pendingRequestsLock.Unlock() diff --git a/client/constants.go b/client/constants.go index a741697..0f266e5 100644 --- a/client/constants.go +++ b/client/constants.go @@ -1,6 +1,9 @@ package client -import "time" +import ( + "reflect" + "time" +) const ( // DefaultRequestTimeout is the default timeout for client request. @@ -10,3 +13,5 @@ const ( // handled by Client and Server. DefaultPendingMessages = 32 * 1024 ) + +var uint64Type = reflect.TypeOf(uint64(0))