Fix concurrency issue with writes
This commit is contained in:
parent
17704469cc
commit
06f1d59b3f
|
@ -102,6 +102,9 @@ func (t *TwitchPubSub) Open() error {
|
||||||
if len(t.SubscribedTopics) > 0 {
|
if len(t.SubscribedTopics) > 0 {
|
||||||
return t.listen(t.SubscribedTopics)
|
return t.listen(t.SubscribedTopics)
|
||||||
} else {
|
} else {
|
||||||
|
t.wsMutex.Lock()
|
||||||
|
defer t.wsMutex.Unlock()
|
||||||
|
t.LastPing = time.Now()
|
||||||
return t.wsConn.WriteJSON(&twitchMessage{Type: Ping})
|
return t.wsConn.WriteJSON(&twitchMessage{Type: Ping})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue