API Reference

Stefan Dühring edited this page Jun 9, 2013 · 1 revision


  pg.noConflict   : fn  - reset namespace
  pg.VERSION      : obj - refers to the current version
  pg.info         : obj - information about the state
  pg.config       : fn  - configuration for the network
  pg.login        : fn  - set identifier and create player
  pg.player       : obj - own user instance (writeable)
  pg.peers        : obj - list of connected players (readable)
  pg.data         : arr - shortcut to access peers.data + player.data
  pg.sync         : obj - synchronized shared object
  pg.loop         : fn  - synchronized rendering process
  pg.channel      : fn  - handler for a "Channel"
  pg.game         : fn  - handler for a "Game"
  pg.routes       : fn  - define default and custom routes
  • pg



Retrieving the old value of the namespace pg.

// Example


Shows information about the current version.

  codeName - {String} - projectname of the release
  full     - {String} - 
  major    - {Number} - 
  minor    - {Number} -
  dot      - {Number} -


Contains various information about the current state & network.

  route    - {String} - current route of the player

.config( [customConfig] )

Changes the configuration with custom settings.

  • customConfig - {Object}:

.login( name, [service] )

Creates a new instance of player (enables pg.player) and



.loop( render )

.routes( [customRoutes], [defaultRoute] )

Defines custom routes to match the parameters in the URL. If just one paremeter is provided, it will use as the new defaultRoute.


The user model contains information about the account, the position and data.

  account  - {Object} -
  data     - {Object} -
  pos      - {Number} -
  id       - {String} -



Read/Write access. Your instance, which will be synced as a peer on other systems.


Read access. Data from other player which will updated as their remote origin changes.



.channel( [name], hook )

.game( [name], hook )

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.