A realtime web framework for dart.
With this framework communication between client and server becomes easy, without any boilerplate code.
Dart Force is a Realtime web framework for Dart. We will make it easy for you to create realtime applications with it in Dart, like a chat, interactive dashboard, multiplayer games, ...
First of all you need a server to handle incoming messages and dispatch or handle this messages correctly.
import "package:force/force_serverside.dart";
ForceServer fs = new ForceServer();
main() async{
fs.server.use("/", (req, model) => "dartforcetodo");
await fs.start();
fs.on("add", (vme, sender) {
fs.send("update", vme.json);
});
}
The client can listen to messages:
ForceClient fc;
void main() {
fc = new ForceClient();
fc.connect();
fc.onConnected.listen((e) {
fc.on("update", (fme, sender) {
querySelector("#list").appendHtml("<div>${fme.json["todo"]}</div>");
});
});
}
You can also send messages:
InputElement input = querySelector("#input");
var data = {"todo": input.value};
fc.send("add", data);
It is a little bit inspired by socket.io for the communication flow.
You have access to the force mvc webserver if you do the following:
forceServer.server.on(url, controllerHandler, method: 'GET');
or just create a controller class. For more info go to the project page of force mvc
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, so that force can interpret the websocket stream of shelf.
Force force = new Force();
var _handlerws = webSocketHandler((webSocket) => force.handle(new StreamSocket(webSocket)));
More info on the wiki page
This guide can help you to get you started! Getting started
- Reference
Look at our wiki for more info or this info below.
You can find a lot of examples in the force examples organisation
Links to some examples that I made with this framework.
Following the next steps will make it easier for you to develop, this allows you to adapt clientside files and immidiatly see results without doing a pub build.
pub serve web --hostname 0.0.0.0 --port 7777 &&
export DART_PUB_SERVE="http://localhost:7777" &&
pub run bin/server.dart
It is also possible to do server 2 server communication. You can find the more info here
or you can watch the video
If you'd like to contribute back to the core, you can fork this repository and send us a pull request, when it is ready.
If you are new to Git or GitHub, please read this guide first.
Follow us on twitter https://twitter.com/usethedartforce
Follow us on google+
or join our G+ Community
Screencast todo tutorial about the dart force realtime functionality on youtube