diff --git a/client.go b/client.go index 47acc1f..58d0da1 100644 --- a/client.go +++ b/client.go @@ -189,7 +189,10 @@ func (c *Client) Resume(state SMState) error { func (c *Client) Disconnect() { _ = c.SendRaw("") // TODO: Add a way to wait for stream close acknowledgement from the server for clean disconnect - _ = c.conn.Close() + conn := c.conn + if conn != nil { + _ = conn.Close() + } } func (c *Client) SetHandler(handler EventHandler) { diff --git a/component.go b/component.go index 2070006..443962d 100644 --- a/component.go +++ b/component.go @@ -123,7 +123,10 @@ func (c *Component) Resume(sm SMState) error { func (c *Component) Disconnect() { _ = c.SendRaw("") // TODO: Add a way to wait for stream close acknowledgement from the server for clean disconnect - _ = c.conn.Close() + conn := c.conn + if conn != nil { + _ = conn.Close() + } } func (c *Component) SetHandler(handler EventHandler) {