Debian Codegraph @

examples/websocket.html

raw symbols SCIP
1 <!doctype html>
2 <html>
3 <head>
4 <title>WebSocket</title>
5 </head>
6 <body>
7 <div>
8 <h4>Slider Output</h4>
9 <div id="sliderValue">slider value: 50</div>
10 <input type="range" id="slider"></input>
11
12 </div>
13 <div>
14 <h4>Csound Input</h4>
15 <div id="inputValue">input value: ?</div>
16 </div>
17 <script>
18 var sliderValue = document.getElementById("sliderValue");
19 var inputValue = document.getElementById("inputValue");
20 var slider = document.getElementById("slider");
21 slider.oninput = function() {
22 sliderValue.innerHTML = "slider value:" + slider.value;
23 websocketOut.send(new Float64Array([slider.value]));
24 }
25 var websocketIn = new WebSocket("ws://127.0.0.1:8888", "klfo");
26 var websocketOut = new WebSocket("ws://127.0.0.1:8888", "kinput");
27 websocketIn.binaryType = 'arraybuffer';
28
29 websocketIn.onmessage = function(message){
30
31 messageData = new Float64Array(message.data);
32 inputValue.innerHTML = messageData[0];
33
34 }
35 </script>
36 </body>
37 </html>