Class Multiplayer

Object
   |
   +--Multiplayer

class Multiplayer


This is the core object of the multiplayer interface. Typically, this interface is used by constructing a new object, registering a listener to hear when the login is complete, and calling the login() function.

A typical instance might look like this:

var multiplayer = new Multiplayer();

multiplayer.addEventListener("login", onLogin, false);
multiplayer.login("myusername", "GameName");

function onLogin(event)
{
    //do something
}
In order for this class to work, the checkMessages() function must be called on a regular basis. In Flash code, this can be called from onEnterFrame(). In Javascript code, it can be called from setInterval() or setTimeout().


Defined in Multiplayer.js


Field Summary
 Game game
          This object holds the status of the current game.
 String username
          The username seen by the server and other users.
 
Constructor Summary
Multiplayer ()
            Create a new multiplayer session.
 
Method Summary
 void addEventListener(<String> type, <Function> handler, <boolean> capture)
           Registers an event listener for a given event.
 void checkMessages()
           This function must be called on a regular basis for messages to be processed.
 void dispatchEvent(<Event> event)
           Fires an event off to all registered listeners.
 boolean isWii()
           Used to detect if we are running on the Nintendo Wii or not.
 void login(<String> username, <String> gamename)
           This object will not establish a connection to the server until this function is called.
 void removeEventListener(<String> type, <Function> handler, <boolean> capture)
           Removes a previously registered event handler.
 String toString()
           Returns "[Object Multiplayer]" to help distinguish the type of the object.

Field Detail

game

Game game

username

String username

Constructor Detail

Multiplayer

Multiplayer()
Method Detail

addEventListener

void addEventListener(<String> type, <Function> handler, <boolean> capture)

checkMessages

void checkMessages()

dispatchEvent

void dispatchEvent(<Event> event)

isWii

boolean isWii()

login

void login(<String> username, <String> gamename)

removeEventListener

void removeEventListener(<String> type, <Function> handler, <boolean> capture)

toString

String toString()