From 9c99f0d3a6b9445f1451903b87ff7011511a8036 Mon Sep 17 00:00:00 2001 From: tyler Date: Mon, 15 Apr 2024 14:58:26 -0400 Subject: [PATCH] Check if chat info has been initialized before starting chat stream --- chat.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chat.go b/chat.go index 3b64484..ea47182 100644 --- a/chat.go +++ b/chat.go @@ -281,6 +281,14 @@ func (c *Client) StartChatStream(handle func(cv ChatView), handleError func(err return pkgErr("", fmt.Errorf("chat stream already started")) } sseEvent := make(chan *sse.Event) + + if c.chatInfo == nil { + ci, err := c.getChatInfo() + if err != nil { + return pkgErr("error getting chat info", err) + } + c.chatInfo = ci + } sseCl := sse.NewClient(c.chatInfo.StreamUrl()) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) sseCl.ReconnectStrategy = backoff.WithContext(