Add support for connection handlers

This commit is contained in:
Elara 2022-12-12 18:36:56 -08:00
parent defecf60ce
commit 4487f18e83

View File

@ -59,6 +59,19 @@ func NewWebSocket(baseURL string) (*WSClient, error) {
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 {
u := &url.URL{}
*u = *c.baseURL