This commit is contained in:
AlexandreRouma
2025-11-04 16:07:18 -05:00
parent 140bc3c3f5
commit f494612908
11 changed files with 411 additions and 445 deletions

View File

@@ -21,7 +21,10 @@ func wsHandler(respWriter http.ResponseWriter, req *http.Request) {
defer sock.Close()
// Receive the init message
msg := recvMessage(sock, 5000)
msg, err := recvMessage(sock, 5000)
// If there was an error or timeout, give up on the connection
if err != nil { return }
// If it's not an init message, give up
if msg.mtype != "init" { return }
@@ -34,9 +37,14 @@ func wsHandler(respWriter http.ResponseWriter, req *http.Request) {
case "display":
// Check that the display has provided its ID
if msg.arguments["dispID"] == nil { return }
dispID, valid := msg.arguments["dispID"].(string)
if !valid { return }
// Check that the display has provided its OTP
otp, valid := msg.arguments["otp"].(string)
if !valid { return }
// Handle as a display
displayHandler(sock, msg.arguments["dispID"].(string))
displayHandler(sock, dispID, otp)
}
}