Realtime tick-based synchronization module for NodeJS
JavaScript CSS
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
package.json is a realtime tick-based synchronization module for NodeJS built on top of


##Installation ####Install Node module Use npm to install Alternatively, you may download the server-side script directly from here.

npm install

Note: has only been tested with the 0.9.x branch of

####Listen on server must be included after

var app = require('http').createServer(handler),
    io = require('').listen(app, {log:false}),
	tick = require('');


####Include client-side script Download the client-side script directly from here.

<!DOCTYPE html>
	<script type="text/javascript" src="/path/to/"></script>
	<script type="text/javascript" src="/path/to/tick.js"></script>

All done!

##How to use You can feel free to check out the examples directory for working use-cases.

On the client side, a bare minimum app must connect to a server and should have a catch-all callback defined.

<!DOCTYPE html>
	<script type="text/javascript" src="/path/to/"></script>
	<script type="text/javascript" src="/path/to/tick.js"></script>
	<script type="text/javascript">
		var mySuperCallback = function(eventName, inObj){
			//Handle different events here. Both arguments are guaranteed to exist.
			//Using a switch is recommended, however, you are free to control the flow
			//of your app however you wish.
			//For example, using if's:
			if(eventName == "tick")
			else if(eventName == "incoming")
				console.log("Data! ", inObj);
		tick.connect("localhost", mySuperCallback).start();

##Events Note: In, an event is guaranteed to exist and is always a string.


  • description: The connect event is fired whenever a new remote connection is established.
  • example: Client A connects, clients B and C will receive the connect event.


  • description: The disconnect event is fired whenever the connection to a remote client is lost.
  • example: Client A disconnects, clients B and C will receive the disconnect event.


  • description: The incoming event is fired when data from a remote connection is delivered to a client.
  • example: Client A sends data, clients B and C will receive the incoming event.


  • description: The init event is fired locally only for the client that has successfully connected to the server.
  • example: Client A connects, client A recieves the init event.


  • description: The start event is fired after the desired number of remote connections (default: 0) is established. The start event signifies that will begin synchronization.
  • example: If the desired number of connections is 3 and clients A and B are connected, then clients A, B, and C will receive the start event after client C connects. If client D later connects, then only client D will receive the start event.


  • description: The tick event is fired at specified time intervals. It enables a client to send data to remote clients at a predictable rate.
  • example: x milliseconds pass, clients A, B, and C will each receive their own respective tick events. These tick events are not guaranteed to fire at the same time.

##Object Properties For the sake of clarity, inObj will refer to the object passed into your catch-all callback function as the second argument. However, it is important to note that the actual name of this object is arbitrary. The following properties are automatically accessible by your callback, although some of these properties may not always be set (see Events).

  • type: arbitrary
  • description: data is the information sent to this client by a remote client. Data can be anything and is not used by directly. As the developer, it is up to you to determine what data is and how you will process it.


  • type: string
  • description: origin is the socket ID of the remote connection which produced the event.


  • type: array
  • description: pool is the list of all remote socket ID's currently able to communicate with this client. The length of pool can be used to determine the number of other clients connected to this client.


  • type: number
  • description: tick is a message counter that is unique per client. All messages from clients are also given a tick number.