Copy of github.com/askrobots/network-computer (MIT): a desk you reach from anything. The original lives on GitHub.

2 downloads

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

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

GitStable demo README: say this is a copy and where the original is cde82c2 13 hours, 42 minutes ago History
proto.go · 3.8 KB · 71 lines
1// Package proto defines the signaling messages exchanged through nc-rendezvous
2// and the input events carried on the WebRTC data channel.
3package proto
4
5import "encoding/json"
6
7// Message is the envelope for everything that crosses the signaling WebSocket.
8// The rendezvous only looks at Type, To and Name; it fills in From.
9type Message struct {
10 Type string `json:"type"` // register, hosts, offer, answer, ice, error
11 Name string `json:"name,omitempty"` // register: host name
12 To string `json:"to,omitempty"` // routing target: host name or client id
13 From string `json:"from,omitempty"` // filled by the rendezvous
14
15 SDP string `json:"sdp,omitempty"` // offer / answer
16 PIN string `json:"pin,omitempty"` // offer: the host PIN the client was given
17 Pair string `json:"pair,omitempty"` // offer: a pairing token instead of the PIN; answer: a fresh one
18 Candidate json.RawMessage `json:"candidate,omitempty"` // ice: RTCIceCandidateInit as JSON
19 Hosts []string `json:"hosts,omitempty"` // hosts reply
20 Error string `json:"error,omitempty"`
21}
22
23// ICEServer mirrors the browser's RTCIceServer shape so /config can be fed
24// straight into a RTCPeerConnection and into Pion.
25type ICEServer struct {
26 URLs []string `json:"urls"`
27 Username string `json:"username,omitempty"`
28 Credential string `json:"credential,omitempty"`
29}
30
31// Config is what GET /config returns. Mode is "secure" (signaling over TLS)
32// or "insecure" (plain HTTP) so clients can show which posture they are in.
33type Config struct {
34 ICEServers []ICEServer `json:"iceServers"`
35 Mode string `json:"mode,omitempty"`
36}
37
38// InputEvent is one message on the "input" data channel. JSON for the spike;
39// a packed binary form comes later. Coordinates are normalised 0..1 across the
40// captured display so the client never needs to know the host resolution.
41type InputEvent struct {
42 T string `json:"t"` // mm, mr, md, mu, wh, kd, ku, display, keyboard, clip, clipget, clipnow, clipnone, launch, voice, tz
43 X float64 `json:"x,omitempty"` // mm: absolute normalised position (md/mu too, with At)
44 Y float64 `json:"y,omitempty"` //
45 DX float64 `json:"dx,omitempty"` // mr: relative move in pixels; wh: scroll delta in pixels
46 DY float64 `json:"dy,omitempty"` //
47 B int `json:"b,omitempty"` // md/mu: 0 left, 1 middle, 2 right
48 // md/mu: X,Y say where the press happened. Moves travel on an unordered
49 // channel and can arrive after the press; the host moves there first.
50 At bool `json:"at,omitempty"`
51 Code string `json:"code,omitempty"` // kd/ku: KeyboardEvent.code, e.g. "KeyA"
52 W int `json:"w,omitempty"` // display: requested screen width in pixels
53 H int `json:"h,omitempty"` // display: requested screen height
54 S float64 `json:"s,omitempty"` // display: UI scale, 1 = 100%
55 // keyboard: the client's layout, e.g. "us", "us:dvorak". Keys travel as
56 // physical positions, so the host must turn them into characters with the
57 // same layout the client uses.
58 Layout string `json:"layout,omitempty"`
59 // clip: clipboard text, in pieces; More is set on every piece but the last.
60 Text string `json:"text,omitempty"`
61 More bool `json:"more,omitempty"`
62 // voice: On starts or stops listening (client to host); Kind says what an
63 // event from the desk is: state, heard, said, did, error. input (client to
64 // host): Kind is "touch" or "pointer", what the person is using.
65 On bool `json:"on,omitempty"`
66 Once bool `json:"once,omitempty"` // voice: stop listening after one phrase
67 Kind string `json:"kind,omitempty"`
68 // input (client to host): Device is "phone", "tablet" or "desktop", the
69 // kind of screen and hands the person has, next to Kind (touch/pointer).
70 Device string `json:"device,omitempty"`
71}