-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.dart
More file actions
66 lines (56 loc) · 1.87 KB
/
test.dart
File metadata and controls
66 lines (56 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import 'dart:async';
import 'package:socket_io_client/socket_io_client.dart' as IO;
void main() async {
// Create a WebSocket client
final MDnsClient client = MDnsClient();
// Start the client with default options.
await client.start();
bool playing = false;
var socket = IO.io('http://localhost:3000', IO.OptionBuilder()
.setTransports(['websocket']) // Use WebSocket transport
.build());
// Connect to the server
socket.on('connect', (_) {
print('Connected to WebSocket server');
//socket.emit("mdns:add", {"name": "dekstop-hud.wled", "port": 3000});
});
// Listen for 'metadata' events from the server
socket.on('metadata', (data) {
print('Received Metadata: $data');
});
// Listen for 'position' events from the server
socket.on('position', (data) {
print('Received Position: $data ms');
});
// Listen for 'playbackState' events from the server
socket.on('playbackState', (data) {
print('Received Playback State: $data');
playing = data == "Playing";
});
// Handle WebSocket disconnect
socket.on('disconnect', (_) {
print('Disconnected from WebSocket server');
});
//Timer.periodic(Duration(seconds: 5), (timer) {
// print("Sending ${playing ? "pause" : "play"}");
// if(playing) socket.emit('pause', false);
// else socket.emit('play', false);
//});
}
// import 'package:multicast_dns/multicast_dns.dart';
// import 'lib/mdnsInfo.dart';
//
// Future<void> main() async {
// // Parse the command line arguments.
//
// const String name = 'dekstop-hud.player._tcp.local';
// final MDnsClient client = MDnsClient();
// // Start the client with default options.
// await client.start();
//
// // Get the PTR record for the service.
// List<MDnsInfo> records = await availableServices(name, client);
// records.forEach((record) => print(record));
// client.stop();
// print('Done.');
// }