https://github.com/jroblak/melonjs-node-socket.io-boilerplate-example
A multiplayer melonJS + node.js + socket.io game
https://github.com/jroblak/melonjs-node-socket.io-boilerplate-example
game javascript melonjs melonjs-node-socket node nodejs socket
Last synced: about 1 year ago
JSON representation
A multiplayer melonJS + node.js + socket.io game
- Host: GitHub
- URL: https://github.com/jroblak/melonjs-node-socket.io-boilerplate-example
- Owner: jroblak
- Created: 2013-05-21T18:12:27.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2014-04-06T01:46:08.000Z (over 12 years ago)
- Last Synced: 2025-04-14T09:08:15.021Z (about 1 year ago)
- Topics: game, javascript, melonjs, melonjs-node-socket, node, nodejs, socket
- Language: JavaScript
- Size: 8.41 MB
- Stars: 29
- Watchers: 5
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sntp
An SNTP v4 client (RFC4330) for node. Simpy connects to the NTP or SNTP server requested and returns the server time
along with the roundtrip duration and clock offset. To adjust the local time to the NTP time, add the returned `t` offset
to the local time.
Current version: **0.1.1**
[](http://travis-ci.org/hueniverse/sntp)
# Usage
```javascript
var Sntp = require('sntp');
// All options are optional
var options = {
host: 'nist1-sj.ustiming.org', // Defaults to pool.ntp.org
port: 123, // Defaults to 123 (NTP)
resolveReference: true, // Default to false (not resolving)
timeout: 1000 // Defaults to zero (no timeout)
};
// Request server time
Sntp.time(options, function (err, time) {
if (err) {
console.log('Failed: ' + err.message);
process.exit(1);
}
console.log('Local clock is off by: ' + time.t + ' milliseconds');
process.exit(0);
});
```
If an application needs to maintain continuous time synchronization, the module provides a stateful method for
querying the current offset only when the last one is too old (defaults to daily).
```javascript
// Request offset once
Sntp.offset(function (err, offset) {
console.log(offset); // New (served fresh)
// Request offset again
Sntp.offset(function (err, offset) {
console.log(offset); // Identical (served from cache)
});
});
```
To set a background offset refresh, start the interval and use the provided now() method. If for any reason the
client fails to obtain an up-to-date offset, the current system clock is used.
```javascript
var before = Sntp.now(); // System time without offset
Sntp.start(function () {
var now = Sntp.now(); // With offset
Sntp.stop();
});
```