More tests, better functionality, the server serves the dashboard now on configurable ports. websocket stuff fixed, though I dont think data is really being sent / recieved...

This commit is contained in:
Nate Anderson
2025-06-13 17:09:08 -06:00
parent b373a93f0e
commit d34cccc253
65 changed files with 166413 additions and 1801 deletions
+18 -2
View File
@@ -15,9 +15,25 @@ class WebSocketManager {
_connections.add(channel);
Logger.info('WebSocket connection added. Total connections: ${_connections.length}');
// Listen for connection close
// Listen for messages and connection close
channel.stream.listen(
null,
(message) {
try {
final data = jsonDecode(message as String) as Map<String, dynamic>;
final messageType = data['type'] as String?;
// Handle ping messages
if (messageType == 'ping') {
final pongMessage = {
'type': 'pong',
'timestamp': DateTime.now().millisecondsSinceEpoch,
};
channel.sink.add(jsonEncode(pongMessage));
}
} catch (e) {
Logger.error('Error processing WebSocket message: $e');
}
},
onDone: () => _removeConnection(channel),
onError: (error) {
Logger.error('WebSocket connection error: $error');