good morning!!!!

Skip to content
Snippets Groups Projects
Commit e234201d authored by a's avatar a
Browse files

Update websocket_client.go

parent 649169be
Branches
Tags v0.0.9
No related merge requests found
...@@ -140,6 +140,8 @@ type sub_cmd struct { ...@@ -140,6 +140,8 @@ type sub_cmd struct {
} }
func (w *Receiver) subscribe() error { func (w *Receiver) subscribe() error {
w.c.Lock()
defer w.c.Unlock()
return w.c.c.WriteJSON(sub_cmd{Method: "topic_subscribe", Params: []string{w.topic}}) return w.c.c.WriteJSON(sub_cmd{Method: "topic_subscribe", Params: []string{w.topic}})
} }
...@@ -164,8 +166,8 @@ func (w *Receiver) OnPatchRaw(seq int, diffs gjson.RawMessage) error { ...@@ -164,8 +166,8 @@ func (w *Receiver) OnPatchRaw(seq int, diffs gjson.RawMessage) error {
} }
func (w *Receiver) Close() { func (w *Receiver) Close() {
w.c.c.WriteJSON(sub_cmd{Method: "topic_unsubscribe", Params: []string{w.topic}})
w.c.Lock() w.c.Lock()
defer w.c.Unlock() defer w.c.Unlock()
w.c.c.WriteJSON(sub_cmd{Method: "topic_unsubscribe", Params: []string{w.topic}})
delete(w.c.Streams, w.topic) delete(w.c.Streams, w.topic)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment