Module: client/multi

client/multi

Entry point for the client side multi library for developing multiscreen games.
Source:

Example

// configure where multi can find your client side socket.io lib
requirejs.config({
  paths: {
    'socket.io': '/socket.io/socket.io.js'
  }
});

var multiOptions = {
  server: 'http://mySocketioServer/'
};

// init and try to create the session
var multi = multiModule.init(multiOptions);
multi.createSession().then(onSession, onSessionFailed).done();

Classes

Multi

Members

<static> color :module:shared/color

Type:
Source:

<static> EventEmitter :module:client/events.EventEmitter

Type:
Source:

<static> JoiningDisabledError :module:shared/errors.JoiningDisabledError

Type:
Source:

<static> MultiError :module:shared/errors.MultiError

Type:
Source:

<static> NoConnectionError :module:shared/errors.NoConnectionError

Type:
Source:

<static> NoSessionTokenFoundError :module:shared/errors.NoSessionTokenFoundError

Type:
Source:

<static> NoSuchSessionError :module:shared/errors.NoSuchSessionError

Type:
Source:

<static> screens :module:plugins/screens

Type:
Source:

<static> ScriptNameNotAllowedError :module:shared/errors.ScriptNameNotAllowedError

Type:
Source:

<static> SessionFullError :module:shared/errors.SessionFullError

Type:
Source:

<static> token :module:client/token

Type:
Source:

<static> TokenAlreadyExistsError :module:shared/errors.TokenAlreadyExistsError

Type:
Source:

<static> util :module:client/util

Type:
Source:

Methods

<static> init(options) → {module:client/multi~Multi}

Parameters:
Name Type Description
options module:client/multi~MultiOptions to tweak this modules behaviour
Source:
Returns:
the one and only Multi instance
Type
module:client/multi~Multi

Type Definitions

MultiOptions

Type:
  • Object
Properties:
Name Type Argument Description
server full url of a running socket.io server
session SessionOptions <optional>
default options for session creation
Source:

toClient

Option to determine to which client a message should be send (not to which _instance_ on this client).
You can set it to:
  • 'all' - the message will be send to all clients currently connected to this session
  • 'all-but-myself' - the message will be send to all clients currently connected to this session except the sending client
  • 'server' - the message will be send to the game server only
  • [player1, player2] - message will be send to all clients that are represented by players inside this array
  • myPlayer - the message will be send to the client that is represented by myPlayer
Type:
  • string | Array.<string> | module:client/player~Player
Source: