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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user