Add the ability to fetch all servers, fix cpu usage leak again..
This commit is contained in:
@@ -13,19 +13,14 @@ func (h *Handler) ListenForExpiration(ctx context.Context) {
|
||||
// Make a ticker and completion channel that is used to continuously poll the
|
||||
// JWT stored in the session to send events to the socket when it is expiring.
|
||||
ticker := time.NewTicker(time.Second * 30)
|
||||
done := make(chan bool)
|
||||
|
||||
// Whenever this function is complete, end the ticker, close out the channel,
|
||||
// and then close the websocket connection.
|
||||
defer func() {
|
||||
ticker.Stop()
|
||||
done <- true
|
||||
}()
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-done:
|
||||
return
|
||||
case <-ticker.C:
|
||||
{
|
||||
|
||||
@@ -194,6 +194,13 @@ func (h *Handler) HandleInbound(m Message) error {
|
||||
{
|
||||
token, err := NewTokenPayload([]byte(strings.Join(m.Args, "")))
|
||||
if err != nil {
|
||||
// If the error says the JWT expired, send a token expired
|
||||
// event and hopefully the client renews the token.
|
||||
if err == jwt.ErrExpValidation {
|
||||
h.SendJson(&Message{Event: TokenExpiredEvent})
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user