Module Web.SocketIO
- Description
This is an implementation of the Socket.IO server-side communication's driver. It basically is a real-time bidirectional object-oriented communication's protocol for communicating between a webbrowser and a server.
This module supports the following features:
Passing any arbitrarily deep nested data object which can be represented in basic JavaScript datatypes.
In addition to the normal JavaScript datatypes, it also supports passing (nested) binary blobs in an efficient manner.
Every message/event sent, allows for a callback acknowledge to be specified.
Acknowledge callbacks which will be called when the other side actively decides to acknowledge it (not automatically upon message reception).
Acknowledgement messages can carry an arbitrary amount of data.
The driver uses Web.EngineIO as the underlying protocol.
- Example
Sample minimal implementation of a SocketIO server farm:
Web.SocketIO.Universe myuniverse; class myclient { inherit Web.SocketIO.Client; } void echo(myclient id, function sendack, string namespace, string event, mixed ... data) { id->emit(event, @data); if (sendack) sendack("Ack","me","harder"); } void wsrequest(array(string) protocols, object req) { httprequest(req); } void httprequest(object req) { switch (req.not_query) { case "/socket.io/": myclient client = myuniverse.farm(myclient, req); if (client) client->emit("Hello world!"); break; } } int main(int argc, array(string) argv) { myuniverse = Web.SocketIO.Universe(); // Create universe myuniverse.register("", echo); // Register root namespace Protocols.WebSocket.Port(httprequest, wsrequest, 80); return -1; }
- See also
farm
, Web.EngineIO, Protocols.WebSocket, http://github.com/socketio/socket.io-protocol, http://socket.io/