equal
deleted
inserted
replaced
21 }; |
21 }; |
22 |
22 |
23 // Open WebSocket to relative "/ws" address |
23 // Open WebSocket to relative "/ws" address |
24 var has_watchdog = window.location.hash == "#watchdog"; |
24 var has_watchdog = window.location.hash == "#watchdog"; |
25 |
25 |
26 var ws_url = |
26 var ws_url = |
27 window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') |
27 window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') |
28 + '?mode=' + (has_watchdog ? "watchdog" : "multiclient"); |
28 + '?mode=' + (has_watchdog ? "watchdog" : "multiclient"); |
29 |
29 |
30 var ws = new WebSocket(ws_url); |
30 var ws = new WebSocket(ws_url); |
31 ws.binaryType = 'arraybuffer'; |
31 ws.binaryType = 'arraybuffer'; |
146 }; |
146 }; |
147 }; |
147 }; |
148 |
148 |
149 const typedarray_types = { |
149 const typedarray_types = { |
150 INT: (number) => new Int16Array([number]), |
150 INT: (number) => new Int16Array([number]), |
151 BOOL: (truth) => new Int16Array([truth]), |
151 BOOL: (truth) => new Int8Array([truth]), |
152 NODE: (truth) => new Int16Array([truth]), |
152 NODE: (truth) => new Int8Array([truth]), |
153 REAL: (number) => new Float32Array([number]), |
153 REAL: (number) => new Float32Array([number]), |
154 STRING: (str) => { |
154 STRING: (str) => { |
155 // beremiz default string max size is 128 |
155 // beremiz default string max size is 128 |
156 str = str.slice(0,128); |
156 str = str.slice(0,128); |
157 binary = new Uint8Array(str.length + 1); |
157 binary = new Uint8Array(str.length + 1); |