Skip to content

fix v2 websocket response types for info,unsubscribed,error,conf #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions v2/websocket_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ func (b *bfxWebsocket) onEvent(msg []byte) (interface{}, error) {
return nil, err
}

var e interface{}
switch event.Event {
case "info":
e = InfoEvent{}
i := InfoEvent{}
err := json.Unmarshal(msg, &i)
return i, err
case "auth":
// TODO: should the lib itself keep track of the authentication
// status?
Expand Down Expand Up @@ -111,15 +112,18 @@ func (b *bfxWebsocket) onEvent(msg []byte) (interface{}, error) {
b.subMu.Unlock()
return s, nil
case "unsubscribed":
e = UnsubscribeEvent{}
u := UnsubscribeEvent{}
err := json.Unmarshal(msg, &u)
return u, err
case "error":
e = ErrorEvent{}
e := ErrorEvent{}
err := json.Unmarshal(msg, &e)
return e, err
case "conf":
e = ConfEvent{}
c := ConfEvent{}
err := json.Unmarshal(msg, &c)
return c, err
default:
return nil, fmt.Errorf("unknown event: %s", msg) // TODO: or just log?
}

err = json.Unmarshal(msg, &e)
return e, err
}