Pike v8.1 release 6

Method Protocols.EngineIO.farm()


Method farm

final Socket farm(Protocols.WebSocket.Request req, void|mapping options)

Parameter 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:

void echo(mixed id, string|Stdio.Buffer msg) {
  id->write(msg);
}

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;
  }
}

int main(int argc, array(string) argv)
{ Protocols.WebSocket.Port(httprequest, wsrequest, 80);
  return -1;
}
See also

Socket.create()