ForceUniverse / dart-force

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

Issue#18 : Create a 'server_client' to allow 2 server talk each other #19

Closed platelk closed 10 years ago

platelk commented 10 years ago

It's a simple implementation of a "ForceClient" for the server side.

This allow this kind of code:

int main() {

ForceClient fc = new ForceClient(host: "127.0.0.1", port: "9223"); ForceServer fs = new ForceServer( port: 9223);

fs.start().then((e) {
  fc.connect();
  fc.onConnected.listen((e) {
    fs.on("test", (e, sendable) {
      print("Receive from server: ${e.json}");
      sendable.send('test', e.json);
      fs.close("Stop");
    });
    fc.on("test", (e, sender) {
      print("Receive from client: ${e.json}");
    });
    fc.send('test', "Trololo");
  });
  fc.onDisconnected.listen((e) {
    print("Deco: ${e}");
  });
});

}