diff --git a/source/Runtime/Client/Webgl/plugin/SimpleWeb.jslib b/source/Runtime/Client/Webgl/plugin/SimpleWeb.jslib index 3d1dbb9..ec6995a 100644 --- a/source/Runtime/Client/Webgl/plugin/SimpleWeb.jslib +++ b/source/Runtime/Client/Webgl/plugin/SimpleWeb.jslib @@ -35,17 +35,17 @@ function Connect(addressPtr, openCallbackPtr, closeCallBackPtr, messageCallbackP const index = SimpleWeb.AddNextSocket(webSocket); // Connection opened - webSocket.addEventListener('open', function (event) { + webSocket.onopen = function (event) { console.log("Connected to " + address); dynCall('vi', openCallbackPtr, [index]); - }); - webSocket.addEventListener('close', function (event) { + } + webSocket.onclose = function (event) { console.log("Disconnected from " + address); dynCall('vi', closeCallBackPtr, [index]); - }); + } // Listen for messages - webSocket.addEventListener('message', function (event) { + webSocket.onmessage = function (event) { if (event.data instanceof ArrayBuffer) { // TODO dont alloc each time var array = new Uint8Array(event.data); @@ -61,13 +61,13 @@ function Connect(addressPtr, openCallbackPtr, closeCallBackPtr, messageCallbackP else { console.error("message type not supported") } - }); + } - webSocket.addEventListener('error', function (event) { + webSocket.onerror = function (event) { console.error('Socket Error', event); dynCall('vi', errorCallbackPtr, [index]); - }); + } return index; }