Added checks for nil values in chat client StopChatStream function
This commit is contained in:
parent
20e55ff1d6
commit
787078f720
13
chat.go
13
chat.go
|
@ -276,9 +276,18 @@ func (c *Client) StartChatStream(handle func(cv ChatView), handleError func(err
|
||||||
func (c *Client) StopChatStream() {
|
func (c *Client) StopChatStream() {
|
||||||
c.chatStreamMu.Lock()
|
c.chatStreamMu.Lock()
|
||||||
defer c.chatStreamMu.Unlock()
|
defer c.chatStreamMu.Unlock()
|
||||||
|
|
||||||
|
if c.chatStream == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
// TODO: what order should these be in?
|
// TODO: what order should these be in?
|
||||||
c.chatStream.sseClient.Unsubscribe(c.chatStream.sseEvent)
|
if c.chatStream.sseClient != nil {
|
||||||
c.chatStream.stop()
|
c.chatStream.sseClient.Unsubscribe(c.chatStream.sseEvent)
|
||||||
|
}
|
||||||
|
if c.chatStream.stop != nil {
|
||||||
|
c.chatStream.stop()
|
||||||
|
}
|
||||||
|
|
||||||
c.chatStream = nil
|
c.chatStream = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue