Compare commits

...

2 Commits

Author SHA1 Message Date
b38c6b0a54 Add support for connection handlers 2022-12-12 18:36:56 -08:00
ce8f58ed2d Update go.mod 2022-12-12 18:23:20 -08:00
3 changed files with 13 additions and 3 deletions

1
go.mod
View File

@ -4,7 +4,6 @@ go 1.19
require ( require (
github.com/google/go-querystring v1.1.0 github.com/google/go-querystring v1.1.0
github.com/mitchellh/mapstructure v1.5.0
github.com/recws-org/recws v1.4.0 github.com/recws-org/recws v1.4.0
) )

2
go.sum
View File

@ -6,8 +6,6 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/recws-org/recws v1.4.0 h1:y9LLddtAicjejikNZXiaY9DQjIwcAQ82acd1XU6n0lU= github.com/recws-org/recws v1.4.0 h1:y9LLddtAicjejikNZXiaY9DQjIwcAQ82acd1XU6n0lU=
github.com/recws-org/recws v1.4.0/go.mod h1:7+NQkTmBdU98VSzkzq9/P7+X0xExioUVBx9OeRKQIkk= github.com/recws-org/recws v1.4.0/go.mod h1:7+NQkTmBdU98VSzkzq9/P7+X0xExioUVBx9OeRKQIkk=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -59,6 +59,19 @@ func NewWebSocket(baseURL string) (*WSClient, error) {
return out, nil return out, nil
} }
// SetConnectHandler sets the connection handler function
func (c *WSClient) SetConnectHandler(f func() error) {
c.conn.SubscribeHandler = f
}
// ConnectHandler invokes the connection handler function
func (c *WSClient) ConnectHandler() error {
if c.conn.SubscribeHandler == nil {
return nil
}
return c.conn.SubscribeHandler()
}
func (c *WSClient) Login(ctx context.Context, l types.Login) error { func (c *WSClient) Login(ctx context.Context, l types.Login) error {
u := &url.URL{} u := &url.URL{}
*u = *c.baseURL *u = *c.baseURL