Skip to content

Commit

Permalink
change ws lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagleft committed Jun 6, 2022
1 parent 2ebbbe6 commit c8de92f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 31 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/Sagleft/utopialib-go
go 1.16

require (
github.com/rgamba/evtwebsocket v0.0.0-20181029234908-48b8cd9f8616 // indirect
github.com/sacOO7/gowebsocket v0.0.0-20210515122958-9396f1a71e23 // indirect
github.com/ctengiz/evtwebsocket v0.0.0-20180717104640-fc3583982591
github.com/rgamba/evtwebsocket v0.0.0-20181029234908-48b8cd9f8616
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect
gopkg.in/grignaak/tribool.v1 v1.0.0-20150312065122-d6bb19d816df
)
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/ctengiz/evtwebsocket v0.0.0-20180717104640-fc3583982591 h1:I+6x3CO8LDrWNe6r6L9y3n3dYXGcKO9BKhJ/dVUYcwc=
github.com/ctengiz/evtwebsocket v0.0.0-20180717104640-fc3583982591/go.mod h1:lpk0rZYe7Oil/0fxAXpasQr7TGtHLSoFIYvk7QnpNEM=
github.com/rgamba/evtwebsocket v0.0.0-20181029234908-48b8cd9f8616 h1:CLOrtba3mh42XMLPr+g89SxpQ7PcdsCQEICO655IsxI=
github.com/rgamba/evtwebsocket v0.0.0-20181029234908-48b8cd9f8616/go.mod h1:fpClUynpFcOmPLy6rXe0pEIoDamYH5s5I0SrbDbF4gk=
github.com/sacOO7/go-logger v0.0.0-20180719173527-9ac9add5a50d h1:5T+fbRuQbpi+WZtB2yfuu59r00F6T2HV/zGYrwX8nvE=
github.com/sacOO7/go-logger v0.0.0-20180719173527-9ac9add5a50d/go.mod h1:L5EJe2k8GwpBoGXDRLAEs58R239jpZuE7NNEtW+T7oo=
github.com/sacOO7/gowebsocket v0.0.0-20210515122958-9396f1a71e23 h1:yjnkNJTpQPCx10KF1jypuIhAVc6EYn2M9lJgwSTHQYs=
github.com/sacOO7/gowebsocket v0.0.0-20210515122958-9396f1a71e23/go.mod h1:h00QywbM5Le22ESUiI8Yz2/9TVGD8eAz/cAk55Kcz/E=
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8=
golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
4 changes: 1 addition & 3 deletions structs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package utopiago

import "github.com/rgamba/evtwebsocket"
import "github.com/ctengiz/evtwebsocket"

// Query is a filter for API requests
type Query struct {
Expand Down Expand Up @@ -62,6 +62,4 @@ type wsHandler struct {
WsURL string
Conn evtwebsocket.Conn
Task WsSubscribeTask

LastMessage []byte
}
22 changes: 2 additions & 20 deletions ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"reflect"

"github.com/rgamba/evtwebsocket"
"github.com/ctengiz/evtwebsocket"
)

// GetString - get string field from ws event.
Expand Down Expand Up @@ -125,26 +125,8 @@ func (h *wsHandler) onMessage(msg []byte, w *evtwebsocket.Conn) {
event, err := newWsEvent(msg)
if err == nil {
h.Task.Callback(event)
return
}

// check message part(s) when message splited to parts
if h.LastMessage == nil {
// wait for new parts
h.LastMessage = msg
return
}

// join message parts
h.LastMessage = append(h.LastMessage, msg...)
event, err = newWsEvent(msg)
if err != nil {
// failed to join message parts
h.LastMessage = msg // use last message as first part to new itterations
h.Task.ErrCallback(err)
return
} else {
h.Task.Callback(event)
h.Task.ErrCallback(err)
}
}

Expand Down

0 comments on commit c8de92f

Please sign in to comment.