Skip to content

Commit

Permalink
Update websockets.go
Browse files Browse the repository at this point in the history
  • Loading branch information
CRossel87a committed May 29, 2023
1 parent f09d6bb commit 2eedea5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions rpc/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"math/big"
"net"
"net/http"
"strconv"
"sync"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -202,8 +203,16 @@ func (s *websocketsServer) readLoop(wsConn *wsConn) {
continue
}

connID, ok := msg["id"].(float64)
if !ok {
var connID float64
switch id := msg["id"].(type) {
case string:
connID, err = strconv.ParseFloat(id, 64)
case float64:
connID = id
default:
err = fmt.Errorf("unknown type")
}
if err != nil {
s.sendErrResponse(
wsConn,
fmt.Errorf("invalid type for connection ID: %T", msg["id"]).Error(),
Expand Down

0 comments on commit 2eedea5

Please sign in to comment.