Skip to content

Commit

Permalink
other: improve login
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <[email protected]>
  • Loading branch information
zhaojh329 committed Apr 16, 2021
1 parent 5c74de3 commit bd59b3c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions broker.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package main

import (
"encoding/binary"
"crypto/x509"
"encoding/binary"
"time"

"github.com/gorilla/websocket"
jsoniter "github.com/json-iterator/go"
Expand Down Expand Up @@ -83,8 +84,10 @@ func (br *broker) run() {
} else {
if dev, ok := br.devices[devid]; ok {
if _, ok := br.waitLoginUsers[devid]; ok {
userLoginAck(loginErrorBusy, c)
log.Error().Msg("login fail, device busy")
log.Error().Msg("Another user is logining the device, wait...")
time.AfterFunc(time.Millisecond*10, func() {
br.register <- c
})
} else {
br.waitLoginUsers[devid] = c
dev.WriteMsg(msgTypeLogin, []byte{})
Expand Down

0 comments on commit bd59b3c

Please sign in to comment.