ForceUniverse / dart-force

Dart Realtime Web Framework!
https://pub.dartlang.org/packages/force
Other
89 stars 9 forks source link

Use its own custom HttpServer for ForceServer is planned ? #20

Closed platelk closed 10 years ago

platelk commented 10 years ago

Hi,

Actually, dart-force use it's own http server implementation for ForceServer.

Is it planned to allow a user to provide its own implementation (like a parameter in the creation of ForceServer) ?

jorishermans commented 10 years ago

Yes you can use the Force without a webserver.

Use the force class for this!

I already did some experiments with Shelf for this!

Force force = new Force();

var wsHandler = webSocketHandler((webSocket) { force.handle(new StreamSocket(webSocket)); });

var myRouter = router(); //myRouter.add("/ws", null, wsHandler);

var staticHandler = createStaticHandler('../build/web', defaultDocument: 'index.html'); myRouter.get("/", staticHandler); myRouter.get("/static/*", staticHandler);

shelf_io.serve(staticHandler, 'localhost', 8080).then((server) { print('Serving at ws://${server.address.host}:${server.port}'); });

/// FORCE // Setup handler for "/text" force.on('text', (e, sendable) {
var json = e.json; sendable.send('text', { 'line': json['line'], 'name': json['name'] });

if (json['line']=='close') {
  force.close(e.wsId);
}

});

platelk commented 10 years ago

Ok, just great !

I was not sure of the right way to do this. thank you very much !

jorishermans commented 10 years ago

You can do this with a connector now! Look at how I did this for the SocketServer ;) I am going to close this issue.