One Flutter client for network-computer: drive a remote Linux/Mac desktop from Android, iPhone, iPad, or desktop over WebRTC.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/network-computer-flutter.git
HTTPS
https://gitstable.com/git/askrobots/network-computer-flutter.git
SSH
ssh://git@gitstable.com:2222/askrobots/network-computer-flutter.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Quellhorst No colour (compare) in ⋯: the desk's picture in grey on this device c74471a 1 month, 3 weeks ago History
protocol.dart · 2.3 KB · 82 lines
1// Mirrors internal/proto/proto.go in the Go repo: signaling messages and input events.
2
3class SignalMessage {
4 String type;
5 String? name, to, from, sdp, pin, pair, error;
6 Map<String, dynamic>? candidate; // RTCIceCandidateInit shape
7 List<String>? hosts;
8
9 SignalMessage({
10 required this.type,
11 this.name,
12 this.to,
13 this.from,
14 this.sdp,
15 this.pin,
16 this.pair,
17 this.error,
18 this.candidate,
19 this.hosts,
20 });
21
22 Map<String, dynamic> toJson() {
23 final m = <String, dynamic>{'type': type};
24 if (name != null) m['name'] = name;
25 if (to != null) m['to'] = to;
26 if (sdp != null) m['sdp'] = sdp;
27 if (pin != null) m['pin'] = pin;
28 if (pair != null) m['pair'] = pair;
29 if (candidate != null) m['candidate'] = candidate;
30 return m;
31 }
32
33 factory SignalMessage.fromJson(Map<String, dynamic> j) => SignalMessage(
34 type: j['type'] ?? '',
35 name: j['name'],
36 to: j['to'],
37 from: j['from'],
38 sdp: j['sdp'],
39 pin: j['pin'],
40 pair: j['pair'],
41 error: j['error'],
42 candidate: (j['candidate'] as Map?)?.cast<String, dynamic>(),
43 hosts: (j['hosts'] as List?)?.cast<String>(),
44 );
45}
46
47/// One message on the "input" data channel. Same JSON the browser client sends.
48/// t: mm (absolute), mr (relative), md/mu (button), wh (wheel), kd/ku (key).
49class InputEvent {
50 final String t;
51 final double? x, y, dx, dy;
52 final int? b;
53 final String? code;
54 InputEvent(this.t, {this.x, this.y, this.dx, this.dy, this.b, this.code});
55
56 Map<String, dynamic> toJson() {
57 final m = <String, dynamic>{'t': t};
58 if (x != null) m['x'] = x;
59 if (y != null) m['y'] = y;
60 if (dx != null) m['dx'] = dx;
61 if (dy != null) m['dy'] = dy;
62 if (b != null) m['b'] = b;
63 if (code != null) m['code'] = code;
64 return m;
65 }
66}
67
68class IceServer {
69 final List<String> urls;
70 final String? username, credential;
71 IceServer(this.urls, {this.username, this.credential});
72 factory IceServer.fromJson(Map<String, dynamic> j) => IceServer(
73 (j['urls'] as List).cast<String>(),
74 username: j['username'],
75 credential: j['credential'],
76 );
77 Map<String, dynamic> toMap() => {
78 'urls': urls,
79 if (username != null) 'username': username,
80 if (credential != null) 'credential': credential,
81 };
82}