Edouard@2783: // svghmi.js Edouard@2783: Edouard@2780: (function(){ Edouard@2783: // Open WebSocket to relative "/ws" address Edouard@2783: var ws = new WebSocket(window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws')); Edouard@2783: Edouard@2783: // Register message reception handler Edouard@2780: ws.onmessage = function (evt) { Edouard@2783: // TODO : dispatch and cache hmi tree updates Edouard@2783: Edouard@2780: var received_msg = evt.data; Edouard@2780: alert("Message is received..."+received_msg); Edouard@2780: }; Edouard@2783: Edouard@2783: // Once connection established Edouard@2780: ws.onopen = function (evt) { Edouard@2783: // TODO : enable the HMI (was previously offline, or just starts) Edouard@2783: // show main page Edouard@2783: Edouard@2780: ws.send("test"); Edouard@2780: }; Edouard@2780: })();