Lelylan full-duplex communication over TCP
Lelylan Websockets is tested against Node 0.10.36.
$ git clone [email protected]:lelylan/websockets.git && cd websockets
$ npm install && npm install -g foreman
$ nf start
Docker image: lelylanlab/websockets
$ docker run -d -it --name websockets lelylanlab/websockets
$ docker build --tag=websockets .
$ docker run -d -it --name websockets websockets
When installing the service in production set lelylan environment variables.
The basic logic behind the websocket microservcie is that when a physical device is updated, changes are broadcasted to all clients who registered to the service with a valid access token.
The realtime service can be integrated in any client who has access to a valid access token.
Install the socket.io library.
<script src="socket.io/socket.io.js"></script>
Connect to the realtime server and sync the device component.
function DashboardCtrl($scope, AccessToken) {
var authorized = (!!AccessToken.get().access_token);
if (authorized) {
// connect to the Websocket service
var socket = io.connect('http://localhost');
socket.on(AccessToken.get().access_token, function (event) {
$scope.fire(event.data);
$scope.$apply(); // needed to refresh the page changes
});
$scope.fire = function(device) {
$rootScope.$broadcast('lelylan:device:request:end', device);
};
socket.on('connected', function (event) {
$scope.connected = true;
$scope.$apply();
})
socket.on('disconnected', function (event) {
$scope.connected = false;
$scope.$apply();
})
}
}
DashboardCtrl.$inject = ['$scope', 'AccessToken'];
See Lelylan Dashboard code for a working implementation.
Fork the repo on github and send a pull requests with topic branches. Do not forget to provide specs to your contribution.
npm install
npm test
Follow Felix guidelines.
Use the issue tracker for bugs or stack overflow for questions. Mail or Tweet us for any idea that can improve the project.
Special thanks to all contributors for submitting patches.
See CHANGELOG
Lelylan is licensed under the Apache License, Version 2.0.