Interacting my lua app (LuaSocket) with my socket.io chat example server

1.6k views Asked by At

I am writing an app for Corona SDK (Using LuaSocket) to be able to subscribe and post messages to the example chat server that runs in socket.io (using gevent-websocket 0.9).

I have checked that chat.js on the server interacts with ther server like this:

To subscribe to a room:

socket.subscribe('room-2000')

Or interacting with the chat room:

socket.send({room: 'room-2000', action: 'start', name: 'John'})

socket.send({room: 'room-2000', action: 'message', message: 'hi there!)});

etc..

Full js client script.

But I don't find a way to make an app for Corona SDK to interact with a channel. I managed to connect to the server with:

socket.connect( my_ip, my_port)

But cannot find a way to subscribe or post/receive messages, can someone give me a clue? Will be highly appreciate it.

1

There are 1 answers

0
Igor Korsakov On

AFAIK, you need to do a WebSocket handshake. Read the WebSocket specifiation. Otherwise, I can recommend you this Publish/Subscribe library for CoronaSDK/Nodejs https://github.com/Overtorment/NoobHub