Struggling to reverse engineer javascript websocket in Corona SDK. Not great at networking.

I am attempting to reverse engineer a web socket library in for Corona SDK.  I am not very familiar with networking, which I think is my problem.  Are there any good tutorials that can help me understand how web sockets work in Javascript and how I can make something analogous in Lua?

Thanks,

Scot

This is very very hard.  We’ve asked Corona to include it here http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3924658-websockets but there has been really no traction.

The difficulty is in the encoding which is easy to do in C or C++ but very difficult in Lua.  There are partial Lua solutions but they all use C++ underneath.  For example here: https://github.com/lipp/lua-websockets

I haven’t found a complete solution so my own project is completely stuck.

I am really new to Conrona SDK but very experienced in software development (30+ years).  My focus has always been user interfaces for educational purposes so I have largely left the networking to others.

I’ve got Lua talking to a UDP server, which is nice and quick.  Is Lua is really c, c++ underneath?  Would it make more sense to call c library for this anyway?  Do you think it would be possible to make a deal with Corona Labs to develop this functionality?

check out my websocket implementation http://github.com/jack9/pusherhub that works with pusher.com

It’s not trivial, but totally possible to make websockets work (you have all the tools you need in lua).

This is very very hard.  We’ve asked Corona to include it here http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3924658-websockets but there has been really no traction.

The difficulty is in the encoding which is easy to do in C or C++ but very difficult in Lua.  There are partial Lua solutions but they all use C++ underneath.  For example here: https://github.com/lipp/lua-websockets

I haven’t found a complete solution so my own project is completely stuck.

I am really new to Conrona SDK but very experienced in software development (30+ years).  My focus has always been user interfaces for educational purposes so I have largely left the networking to others.

I’ve got Lua talking to a UDP server, which is nice and quick.  Is Lua is really c, c++ underneath?  Would it make more sense to call c library for this anyway?  Do you think it would be possible to make a deal with Corona Labs to develop this functionality?

Thanks Jack.  I’ll take a look at your implementation.  We’ve gone in another direction for the moment, but I would like to revisit this later. As I began to dig into it I came to the conclusion it could be done.  It is nice to see an actual implementation.  I’m sure that will be very helpful.

May be back to this topic later.  Hopefully others will find this post.

Thanks,

–Scot

check out my websocket implementation http://github.com/jack9/pusherhub that works with pusher.com

It’s not trivial, but totally possible to make websockets work (you have all the tools you need in lua).

Thanks Jack.  I’ll take a look at your implementation.  We’ve gone in another direction for the moment, but I would like to revisit this later. As I began to dig into it I came to the conclusion it could be done.  It is nice to see an actual implementation.  I’m sure that will be very helpful.

May be back to this topic later.  Hopefully others will find this post.

Thanks,

–Scot

i have published a library module to support WebSockets in Corona.

if you’re interested: http://code.coronalabs.com/code/dmcwebsockets

cheers,

dmc

i have published a library module to support WebSockets in Corona.

if you’re interested: http://code.coronalabs.com/code/dmcwebsockets

cheers,

dmc

Your library doesn’t seem to work.

on build/run it can’t find lua_bytearray.

probably because your folder structure is:

dmc_corona.dmc_websockets

and you call it like 

lib.dmc_bytearray    instead of    dmc_corona.lib.dmc_bytearray

as a quick test, i just ran the example ‘echo’ from both github repos – dmc-websockets and dmc-corona-library (branch 2.0) – on the Mac Sim and everything worked fine.

(btw, branch 2.0 of dmc-corona-lib is same as dmc-websocket repo)

things to check
* if you’re using dmc-corona-lib repo, make sure you have 2.0 branch – ‘dmc_corona-2.x’
* ensure the search PATH in dmc_corona.cfg is correct according to your setup

otherwise i need more info:
* running on ? sim (mac/win), device (iOS/android)
* repo where you got code ? have a fresh checkout, or is it updated ?
* what example are you using to test – echo, pusher, autobahn ?

cheers, dmc

i missed the required files dmc_corona.cfg and dmc_corona_boot.lua 

There was no mentioned requirement for them both.

It would be great if there was a smaller (1-file) library for websockets instead of so much files/folders

Your library doesn’t seem to work.

on build/run it can’t find lua_bytearray.

probably because your folder structure is:

dmc_corona.dmc_websockets

and you call it like 

lib.dmc_bytearray    instead of    dmc_corona.lib.dmc_bytearray

as a quick test, i just ran the example ‘echo’ from both github repos – dmc-websockets and dmc-corona-library (branch 2.0) – on the Mac Sim and everything worked fine.

(btw, branch 2.0 of dmc-corona-lib is same as dmc-websocket repo)

things to check
* if you’re using dmc-corona-lib repo, make sure you have 2.0 branch – ‘dmc_corona-2.x’
* ensure the search PATH in dmc_corona.cfg is correct according to your setup

otherwise i need more info:
* running on ? sim (mac/win), device (iOS/android)
* repo where you got code ? have a fresh checkout, or is it updated ?
* what example are you using to test – echo, pusher, autobahn ?

cheers, dmc

i missed the required files dmc_corona.cfg and dmc_corona_boot.lua 

There was no mentioned requirement for them both.

It would be great if there was a smaller (1-file) library for websockets instead of so much files/folders