diff --git a/pubsub.go b/pubsub.go index 8f59b53..da98d0d 100644 --- a/pubsub.go +++ b/pubsub.go @@ -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}) }