equal
deleted
inserted
replaced
|
1 // svghmi.js |
|
2 |
1 (function(){ |
3 (function(){ |
2 var relative_URI = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws'); |
4 // Open WebSocket to relative "/ws" address |
3 var ws = new WebSocket(relative_URI); |
5 var ws = new WebSocket(window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws')); |
|
6 |
|
7 // Register message reception handler |
4 ws.onmessage = function (evt) { |
8 ws.onmessage = function (evt) { |
|
9 // TODO : dispatch and cache hmi tree updates |
|
10 |
5 var received_msg = evt.data; |
11 var received_msg = evt.data; |
6 alert("Message is received..."+received_msg); |
12 alert("Message is received..."+received_msg); |
7 }; |
13 }; |
|
14 |
|
15 // Once connection established |
8 ws.onopen = function (evt) { |
16 ws.onopen = function (evt) { |
|
17 // TODO : enable the HMI (was previously offline, or just starts) |
|
18 // show main page |
|
19 |
9 ws.send("test"); |
20 ws.send("test"); |
10 }; |
21 }; |
11 })(); |
22 })(); |