Fix concurrency issue with writes

This commit is contained in:
Tyler 2017-05-04 01:40:02 -04:00
parent 17704469cc
commit 06f1d59b3f
1 changed files with 3 additions and 0 deletions

View File

@ -102,6 +102,9 @@ func (t *TwitchPubSub) Open() error {
if len(t.SubscribedTopics) > 0 {
return t.listen(t.SubscribedTopics)
} else {
t.wsMutex.Lock()
defer t.wsMutex.Unlock()
t.LastPing = time.Now()
return t.wsConn.WriteJSON(&twitchMessage{Type: Ping})
}