pike.git / lib / modules / Protocols.pmod / EngineIO.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:1:   /*    * Clean-room Engine.IO implementation for Pike.    */      //! 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 @[Protocol.WebSocket] with + //! 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 - //! @[Protocol.WebSocket] connections from functioning. + //! @[Protocols.WebSocket] connections from functioning.   //!   //! This module supports the following features:   //! @ul   //! @item It supports both UTF-8 and binary packets. - //! @item If both sides support @[Protocol.WebSocket], then + //! @item 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.   //! @endul   //!   //! In most cases, Engine.IO is not used directly in applications. Instead   //! one uses Socket.IO instead.   //!   //! @seealso - //! @[Protocol.SocketIO], @[Protocol.WebSocket], + //! @[Protocols.SocketIO], @[Protocols.WebSocket],   //! @url{http://github.com/socketio/engine.io-protocol@},   //! @url{http://socket.io/@}      #pike __REAL_VERSION__      //#define EIO_DEBUG 1   //#define EIO_DEBUGMORE 1      //#define EIO_STATS 1 // Collect extra usage statistics   
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:93:   private Regexp acceptgzip = Regexp("(^|,)gzip(,|$)");   private Regexp xxsua = Regexp(";MSIE|Trident/");      //! @param options   //! Optional options to override the defaults.   //! This parameter is passed down as is to the underlying   //! @[Socket].   //!   //! @example   //! Sample minimal implementation of an EngineIO server farm: + //! @code + //! void echo(mixed id, string|Stdio.Buffer msg) { + //! id->write(msg); + //! }   //! - //!void echo(mixed id, string|Stdio.Buffer msg) { - //! id->write(msg); - //!} + //! void wsrequest(array(string) protocols, object req) { + //! httprequest(req); + //! }   //! - //!void wsrequest(array(string) protocols, object req) { - //! httprequest(req); - //!} + //! void httprequest(object req) + //! { switch (req.not_query) + //! { case "/engine.io/": + //! Protocols.EngineIO.Socket client = Protocols.EngineIO.farm(req); + //! if (client) { + //! client.set_callbacks(echo); + //! client.write("Hello world!"); + //! } + //! break; + //! } + //! }   //! - //!void httprequest(object req) - //!{ switch (req.not_query) - //! { case "/engine.io/": - //! Protocols.EngineIO.Socket client = Protocols.EngineIO.farm(req); - //! if (client) { - //! client.set_callbacks(echo); - //! client.write("Hello world!"); - //! } - //! break; - //! } - //!} + //! int main(int argc, array(string) argv) + //! { Protocols.WebSocket.Port(httprequest, wsrequest, 80); + //! return -1; + //! } + //! @endcode   //! - //!int main(int argc, array(string) argv) - //!{ Protocols.WebSocket.Port(httprequest, wsrequest, 80); - //! return -1; - //!} - //! +    //! @seealso   //! @[Socket.create()]   final Socket farm(Protocols.WebSocket.Request req, void|mapping options) {    string sid;    PD("Request %O\n", req.query);    if (sid = req.variables.sid) {    Socket client;    if (!(client = clients[sid]))    req.response_and_finish((["data":"Unknown sid",    "error":Protocols.HTTP.HTTP_GONE]));
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:680:       protected void destroy() {    close();    }       //! @param options    //! Optional options to override the defaults.    //! @mapping    //! @member int "pingTimeout"    //! If, the connection is idle for longer than this, the connection -  //! is terminated, unit in @expr{ms}. +  //! is terminated, unit in @expr{ms@}.    //! @member int "pingInterval"    //! The browser-client will send a small ping message every -  //! @expr{pingInterval ms}. +  //! @expr{pingInterval ms@}.    //! @member int "allowUpgrades" -  //! When @expr{true} (default), it allows the server to upgrade -  //! the connection to a real @[Protocol.WebSocket] connection. +  //! When @expr{true@} (default), it allows the server to upgrade +  //! the connection to a real @[Protocols.WebSocket] connection.    //! @member int "compressionLevel"    //! The gzip compressionlevel used to compress packets.    //! @member int "compressionThreshold"    //! Packets smaller than this will not be compressed.    //! @endmapping    protected void create(Protocols.WebSocket.Request req,    void|mapping options) {    request = req;    _options = .EngineIO.options;    if (options && sizeof(options))