Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cmd/managementd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func handleConn(conn net.Conn) error {
log.Println("Error reading frame ", err)
return err
}
if len(sockets) == 0 {
if !hasActiveClients() {
continue
}
if err := lepton3.ParseRawFrame(rawFrame, frame, 0); err != nil {
Expand Down Expand Up @@ -469,9 +469,11 @@ func WebsocketServer(ws *websocket.Conn) {
}
}
if message.Type == "Heartbeat" {
socketsLock.Lock()
if socket, ok := sockets[message.Uuid]; ok {
socket.LastHeartbeatAt = time.Now()
}
socketsLock.Unlock()
}
}
time.Sleep(1 * time.Millisecond)
Expand All @@ -496,7 +498,7 @@ func sendFrameToSockets() {
// NOTE: Only bother with this work if we have clients connected.
lastFrame = <-frameCh

if len(sockets) != 0 {
if hasActiveClients() {
if lastFrame.Disconnected {
socketsLock.RLock()
for uuid, socket := range sockets {
Expand Down
2 changes: 1 addition & 1 deletion management-interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func getDeviceName() string {
return strings.SplitN(name, ".", 2)[0]
}

// Return the serial number for the Raspberr Pi in the device.
// Return the serial number for the Raspberry Pi in the device.
func getRaspberryPiSerialNumber() string {
if runtime.GOOS == "windows" {
return ""
Expand Down