Corona HTML5 WebSockets plugin

Hi,

If you’d like to integrate WebSockets into your HTML5 builds you can find a plugin here https://github.com/develephant/corona-html5-websockets-plugin

If you are using the WebSockets plugin for device builds, see this documentation for how to create a hybrid build.

-dev

Thanks!
But 71.8 kb js? o_O

This is not enough?

window.wsjs\_js = { connect: function (uri) { var ws = new WebSocket(uri); // успешно установили соединение ws.onopen = function (d) { wsjs\_js.cb({type: 'OnOpen0'}); }; // закрытие сокета ws.onclose = function (err) { wsjs\_js.cb({type: 'OnClose0'}); }; // ловим ошибки ws.onerror = function(err) { console.error('err', err); wsjs\_js.cb({type: 'OnError0'}); }; // получаем сообщения ws.onmessage = function(mes) { wsjs\_js.cb({type: 'OnMessage0', data: mes.data}); }; }, // добавим коллбек addEventListener: function(cb) { wsjs\_js.cb = LuaCreateFunction(cb); }, // удаляем коллбек removeEventListener: function(cb) { LuaReleaseFunction(wsjs\_js.cb); wsjs\_js.cb = null; } };

For multiple connections, can make class

P.S. Why websockets (for lua) not working with ws://localhost:3000 … in simulator? Not connecting

Hi,

Admittedly mine is not optimized, I just threw it together quickly using a Node module so it probably has unneeded overhead. I’ll clean it up a bit later.

Refactored. 1.39kb

I’ll have to check and see why localhost isn’t working, did you try 127.0.0.1?

-dev

Yes, I’ve tried ws://127.0.0.1:3000 and ws://(MyMacName).local:3000
 

may 07 11:44:42.843 ws connecting ws://127.0.0.1:3000/wsm

may 07 11:44:48.845 disconnected nil nil

6 sec for auto disconnect (OnClose0)?

after build html5 - localhost work with my js plugin

I launch server localhost on nodejs

Hi,

Localhost is working fine on my tests.

https://www.youtube.com/watch?v=UsJh4fWzFKU

macOS 10.13.4

websocketd

If the Corona simulator, or the HTML5 page, is in the background then you will experience a networking delay. It has nothing to do with the plugin(s).

-dev

Oh! I’m sorry! I missed argument PORT. And wrote uri as ws:connect(“ws://localhost:3000/path”)
Thank you, it’s works!)

Thanks!
But 71.8 kb js? o_O

This is not enough?

window.wsjs\_js = { connect: function (uri) { var ws = new WebSocket(uri); // успешно установили соединение ws.onopen = function (d) { wsjs\_js.cb({type: 'OnOpen0'}); }; // закрытие сокета ws.onclose = function (err) { wsjs\_js.cb({type: 'OnClose0'}); }; // ловим ошибки ws.onerror = function(err) { console.error('err', err); wsjs\_js.cb({type: 'OnError0'}); }; // получаем сообщения ws.onmessage = function(mes) { wsjs\_js.cb({type: 'OnMessage0', data: mes.data}); }; }, // добавим коллбек addEventListener: function(cb) { wsjs\_js.cb = LuaCreateFunction(cb); }, // удаляем коллбек removeEventListener: function(cb) { LuaReleaseFunction(wsjs\_js.cb); wsjs\_js.cb = null; } };

For multiple connections, can make class

P.S. Why websockets (for lua) not working with ws://localhost:3000 … in simulator? Not connecting

Hi,

Admittedly mine is not optimized, I just threw it together quickly using a Node module so it probably has unneeded overhead. I’ll clean it up a bit later.

Refactored. 1.39kb

I’ll have to check and see why localhost isn’t working, did you try 127.0.0.1?

-dev

Yes, I’ve tried ws://127.0.0.1:3000 and ws://(MyMacName).local:3000
 

may 07 11:44:42.843 ws connecting ws://127.0.0.1:3000/wsm

may 07 11:44:48.845 disconnected nil nil

6 sec for auto disconnect (OnClose0)?

after build html5 - localhost work with my js plugin

I launch server localhost on nodejs

Hi,

Localhost is working fine on my tests.

https://www.youtube.com/watch?v=UsJh4fWzFKU

macOS 10.13.4

websocketd

If the Corona simulator, or the HTML5 page, is in the background then you will experience a networking delay. It has nothing to do with the plugin(s).

-dev

Oh! I’m sorry! I missed argument PORT. And wrote uri as ws:connect(“ws://localhost:3000/path”)
Thank you, it’s works!)