Skip to content

Commit

Permalink
if else chain to switch
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Coffman <steve@khanacademy.org>
  • Loading branch information
StevenACoffman committed May 26, 2022
1 parent a7323ba commit 64b882c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions client/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ func (p *Client) WebsocketOnce(query string, resp interface{}, options ...Option
return sock.Next(&resp)
}

func (p *Client) WebsocketWithPayload(query string, initPayload map[string]interface{}, options ...Option) *Subscription {
func (p *Client) WebsocketWithPayload(
query string,
initPayload map[string]interface{},
options ...Option,
) *Subscription {
r, err := p.newRequest(query, options...)
if err != nil {
return errorSubscription(fmt.Errorf("request: %w", err))
Expand Down Expand Up @@ -116,11 +120,12 @@ func (p *Client) WebsocketWithPayload(query string, initPayload map[string]inter
return err
}
if op.Type != dataMsg {
if op.Type == connectionKaMsg {
switch op.Type {
case connectionKaMsg:
continue
} else if op.Type == errorMsg {
case errorMsg:
return fmt.Errorf(string(op.Payload))
} else {
default:
return fmt.Errorf("expected data message, got %#v", op)
}
}
Expand Down

0 comments on commit 64b882c

Please sign in to comment.