Module Web.EngineIO
- Description
This is an implementation of the Engine.IO server-side communication's driver. It basically is a real-time bidirectional packet-oriented communication's protocol for communicating between a webbrowser and a server.
The driver mainly is a wrapper around Protocols.WebSocket with the addition of two fallback mechanisms that work around limitations imposed by firewalls and/or older browsers that prevent native Protocols.WebSocket connections from functioning.
This module supports the following features:
It supports both UTF-8 and binary packets.
If both sides support Protocols.WebSocket, then packet sizes are essentially unlimited. The fallback methods have a limit on packet sizes from browser to server, determined by the maximum POST request size the involved network components allow.
In most cases, Engine.IO is not used directly in applications. Instead one uses Socket.IO instead.
- Example
Sample small implementation of an EngineIO server farm:
class mysocket { inherit Web.EngineIO.Socket; void echo(string|Stdio.Buffer msg) { write(0, msg); } } void wsrequest(array(string) protocols, object req) { httprequest(req); } void httprequest(object req) { switch (req.not_query) { case "/engine.io/": mysocket client = Web.EngineIO.farm(mysocket, req); if (client) { client.open(client.echo); client.write(0, "Hello world!"); } break; } } int main(int argc, array(string) argv) { Protocols.WebSocket.Port(httprequest, wsrequest, 80); return -1; }
- See also
farm, Web.SocketIO, Protocols.WebSocket, http://github.com/socketio/engine.io-protocol, http://socket.io/