Closed platelk closed 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);
}
});
Ok, just great !
I was not sure of the right way to do this. thank you very much !
You can do this with a connector now! Look at how I did this for the SocketServer ;) I am going to close this issue.
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) ?