Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including voxel-server with all npm packages installed. Try it out:

var voxelServer = require("voxel-server")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

voxel-server v2.1.0

voxel-server

multiplayer server for voxel-engine

Use with voxel-client

Using as a module

The returned server object implements EventEmitter

var Server = require('voxel-server')

var settings = {
  // various [voxel-engine]() settings to be sent to the clients
  avatarInitialPosition: [2, 20, 2],
  // list of incomming custom events to forward to all clients
  forwardEvents: ['attack','voiceChat']
}

// create server
var server = Server(settings)

// bind events
server.on('missingChunk', function(chunk){ ... })
server.on('client.join', function(client){ ... })
server.on('client.leave', function(client){ ... })
server.on('client.state', function(state){ ... })
server.on('chat', function(message){ ... })
server.on('set', function(pos, val, client){ ... })
server.on('error', function(error){ ... })

// connect a client
var duplexStream = SomeTransportSteam()
server.connectClient(duplexStream)

transport streams

websockets: websocket-stream

webRTC: rtc-data-stream

further reading:

  • http://buildnewgames.com/real-time-multiplayer/
  • https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
  • http://www.gabrielgambetta.com/?p=63 (all three parts)
  • http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/
  • http://gafferongames.com/game-physics/networked-physics/
  • http://udn.epicgames.com/Three/NetworkingOverview.html

license

BSD

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free