Merge pull request #13 from Sir3lit/patch-2

Fixes stuck Go-routine
This commit is contained in:
Dane Everitt 2020-01-28 10:49:36 -08:00 committed by GitHub
commit 3f6b0ce44c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -187,17 +187,13 @@ func (rt *Router) routeWebsocket(w http.ResponseWriter, r *http.Request, ps http
// Listen for different events emitted by the server and respond to them appropriately. // Listen for different events emitted by the server and respond to them appropriately.
go func() { go func() {
for { for d := range eventChannel {
select { handler.SendJson(&WebsocketMessage{
case d := <-eventChannel: Event: d.Topic,
handler.SendJson(&WebsocketMessage{ Args: []string{d.Data},
Event: d.Topic, })
Args: []string{d.Data},
})
}
} }
}() }()
// Sit here and check the time to expiration on the JWT every 30 seconds until // Sit here and check the time to expiration on the JWT every 30 seconds until
// the token has expired. If we are within 3 minutes of the token expiring, send // the token has expired. If we are within 3 minutes of the token expiring, send
// a notice over the socket that it is expiring soon. If it has expired, send that // a notice over the socket that it is expiring soon. If it has expired, send that