Skip to content
joris hermans edited this page Apr 16, 2015 · 2 revisions

You can very easily use the power of Force into the shelf stack by using shelf_web_socket package and then use the following code.

   Force force = new Force();
   var _handlerws = webSocketHandler((webSocket) => force.handle(new StreamSocket(webSocket)));

Then you can add this Shelf handler to the shelf stack.

    var handler = new Cascade()
      .add(staticHandler)
      .add(_handlerws)
      .handler;

You can use all the methods you are used to of ForceServer also in Force.

   force.on("add", (msg, sender) {
       sender.send("update", msg.json);
  });

The only thing you then need todo is starting the shelf server.

    io.serve(handler, 'localhost', 8080).then((server) {
       print('Serving at http://${server.address.host}:${server.port}');
    });

We made a working integration project for you.

Clone this wiki locally