Improve socket connection and logging
This commit is contained in:
parent
1917d1d10e
commit
9feab409ab
@ -140,7 +140,8 @@ final class DeviceManager {
|
||||
func createNewDeviceConnection(socket: WebSocket, auth: String) async {
|
||||
guard let key = Data(fromHexEncodedString: auth),
|
||||
SHA256.hash(data: key) == self.deviceKey else {
|
||||
log("Invalid device key")
|
||||
log("Invalid device key while opening socket")
|
||||
try? await socket.close()
|
||||
return
|
||||
}
|
||||
await removeDeviceConnection()
|
||||
@ -149,6 +150,12 @@ final class DeviceManager {
|
||||
socket.eventLoop.execute {
|
||||
socket.pingInterval = .seconds(10)
|
||||
|
||||
socket.onText { socket, text in
|
||||
print("[WARN] Received text over socket: \(text)")
|
||||
// Close connection to prevent spamming the log
|
||||
try? await socket.close()
|
||||
}
|
||||
|
||||
socket.onBinary { [weak self] _, data in
|
||||
self?.processDeviceResponse(data)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user