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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:159:    private function(mixed, string|Stdio.Buffer:void) read_cb;    private function(mixed:void) close_cb;    private Thread.Queue sendq = Thread.Queue();    private ADT.Queue recvq = ADT.Queue();    private string curtransport;    private Transport conn;    private Transport upgtransport;    private enum {RUNNING = 0, PAUSED, SCLOSING, RCLOSING};    private int state = RUNNING;    +  //! Set to any of @expr{Protocols.WebSocket.OVERRIDE_COMPRESS@} +  //! or @expr{Protocols.WebSocket.OVERRIDE_SKIPCOMPRESS@} +  //! to bypass of the compression heuristics on binary +  //! frames in a WebSocket connection only. +  final int skip_compression = .WebSocket.HEURISTICS_COMPRESS; +     class Transport {    final function(int, void|string|Stdio.Buffer:void) read_cb;    final protected int pingtimeout;       protected void create(Protocols.WebSocket.Request req) {    pingtimeout = _options->pingTimeout/1000+1;    kickwatchdog();    }       private void droptimeout() {
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:450:    protected void create(Protocols.WebSocket.Request req,    Protocols.WebSocket.Connection _con) {    con = _con;    con.onmessage = recv;    con.onclose = ::close;    ::create(req);    }       final void flush(void|int type, void|string|Stdio.Buffer msg) {    void sendit() { -  con.send_text(sprintf("%c%s",type,stringp(msg) ? msg : msg->read())); +  if (stringp(msg)) +  con.send_text(sprintf("%c%s", type, msg)); +  else { +  .WebSocket.Frame f = .WebSocket.Frame(.WebSocket.FRAME_BINARY, +  sprintf("%c%s", type - OPEN, msg->read())); +  f.skip_compression = skip_compression; +  con.send(f); +  }    };    if (msg)    sendit();    else {    array tosend;    while (sizeof(tosend = sendq.try_read_array())) {    array m;    foreach (tosend;; m) {    type = m[0];    msg = m[1];
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:492:    break;    default:    return;    }    if (f.fin)    if (sizeof(sb)) {    string s = sb.get();    read_cb(s[0], s[1..]);    } else {    int type = bb->read_int8(); -  read_cb(type, bb->read_buffer(sizeof(bb))); +  read_cb(type + OPEN, bb->read_buffer(sizeof(bb)));    }    }    }       //! Set initial argument on callbacks.    final void set_id(mixed _id) {    id = _id;    }       //! Retrieve initial argument on callbacks. Defaults to the Socket
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:675:    request = req;    _options = .EngineIO.options;    if (options && sizeof(options))    _options += options;    switch (curtransport = req.variables->transport) {    default:    req.response_and_finish((["data":"Unsupported transport",    "error":Protocols.HTTP.HTTP_UNSUPP_MEDIA]));    return;    case "websocket": -  conn = WebSocket(req, req.websocket_accept(0)); +  conn = WebSocket(req, req.websocket_accept(0, _options));    break;    case "polling":    conn = req.variables.j ? JSONP(req) : XHR(req);    break;    }    conn.read_cb = recv;    ci->add(Crypto.Random.random_string(SIDBYTES-TIMEBYTES));    ci->add_hint(gethrtime(), TIMEBYTES);    sid = MIME.encode_base64(ci->read());    clients[sid] = this;
pike.git/lib/modules/Protocols.pmod/EngineIO.pmod:710:    request = req;    if ((s = req.variables->transport) == curtransport)    conn.onrequest(req);    else    switch (s) {    default:    req.response_and_finish((["data":"Invalid transport",    "error":Protocols.HTTP.HTTP_UNSUPP_MEDIA]));    return 0;    case "websocket": -  upgtransport = WebSocket(req, req.websocket_accept(0)); +  upgtransport = WebSocket(req, req.websocket_accept(0, _options));    upgtransport.read_cb = upgrecv;    }    }       private string _sprintf(int type, void|mapping flags) {    string res=UNDEFINED;    switch (type) {    case 'O':    res = sprintf(DRIVERNAME"(%s.%d,%s,%d,%d,%d,%d)",    sid, protocol, curtransport, state, sendq.size(),    recvq.is_empty(),sizeof(clients));    break;    }    return res;    }   }