0.0.8 • Published 9 years ago

ns-unite v0.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

ns-unite

nssocket wrapper for easily synchronizing data between servers.

Installation

$ npm install ns-unite

Usage

ns-unite wraps nssocket in some simple functionality to create a server and connect to it with a client. It exposes a says function on the client for sending messages and and hears event for receiving them.

Create a Server

On one machine you want to create a server like this:

var serverSettings = {
	port: port
};

var server = new nsunite.Server(serverSettings);

server.on('join', function(data, socket) {
	console.log('new join event: ', data);
});

server.on('clientSays', function(data) {
	console.log('clientSays: ', data);
});

server.on('ready', function() {
	console.log('server is ready');
});

server.start();

Create a Client

On lots of other machines you want to create clients like this:

var client = new nsunite.Client(clientSettings);

client.on('ready', function() {
	client.says('wooooo');

	client.says('start the car!');
});

client.on('hears', function(data) {
	console.log('received data: ', data);
});

client.connect();
0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago