net.user1.union.api
Interface ScriptWrapper


public interface ScriptWrapper

A ScriptWrapper acts as a proxy for scripts for event handling. All scripts are passed a ScriptWrapper in the init method. Scripts can then use the wrapper to register for events on the server. JavaScript Example: function init(ctx, wrap) { context = ctx; wrapper = wrap; wrapper.addRoomEventListener(RoomEvent.ADD_CLIENT, "onRoomAddClient"); wrapper.addRoomEventListener(RoomEvent.REMOVE_CLIENT, "onRoomRemoveClient"); } Scripts can then implement the event callback methods normally. JavaScript Example: function onRoomAddClient(evt) { println("Client [" + evt.getClient().getClientID() + "] joined the Room"); }


Method Summary
 void addClientEventListener(Client client, java.lang.String event, java.lang.String method)
          Add a client event listener to the given room.
 void addRoomEventListener(Room room, java.lang.String event, java.lang.String method)
          Add a room event listener to the given room.
 void addRoomEventListener(java.lang.String event, java.lang.String method)
          Add a room event listener to the room to which the room module script is attached.
 void addServerEventListener(java.lang.String event, java.lang.String method)
          Add an event listener to the server.
 void removeClientEventListener(Client client, java.lang.String event, java.lang.String method)
          Remove an event listener from the given client.
 void removeRoomEventListener(Room room, java.lang.String event, java.lang.String method)
          Remove an event listener from the given room.
 void removeRoomEventListener(java.lang.String event, java.lang.String method)
          Remove an event listener from the room to which the room module script is attached.
 void removeServerEventListener(java.lang.String event, java.lang.String method)
          Remove an event listener from the server.
 

Method Detail

addRoomEventListener

void addRoomEventListener(java.lang.String event,
                          java.lang.String method)
Add a room event listener to the room to which the room module script is attached. For scripts that are not a room module this method will simply return with no effect.

Parameters:
event - - the event the script wants to listen to
method - - the method that will be invoked on the script when the event occurs

removeRoomEventListener

void removeRoomEventListener(java.lang.String event,
                             java.lang.String method)
Remove an event listener from the room to which the room module script is attached. For scripts that are not a room module this method will simply return with no effect.

Parameters:
event - - the event the script was listening to
method - - the method that was invoked on the script when the event occurs

addRoomEventListener

void addRoomEventListener(Room room,
                          java.lang.String event,
                          java.lang.String method)
Add a room event listener to the given room.

Parameters:
room - - the room to listen to for the event occurring
event - - the event the script wants to listen to
method - - the method that will be invoked on the script when the event occurs

removeRoomEventListener

void removeRoomEventListener(Room room,
                             java.lang.String event,
                             java.lang.String method)
Remove an event listener from the given room.

Parameters:
room - - the room that was being listened to
event - - the event the script was listening to
method - - the method that was invoked on the script when the event occurs

addClientEventListener

void addClientEventListener(Client client,
                            java.lang.String event,
                            java.lang.String method)
Add a client event listener to the given room.

Parameters:
client - - the room to listen to for the event occurring
event - - the event the script wants to listen to
method - - the method that will be invoked on the script when the event occurs

removeClientEventListener

void removeClientEventListener(Client client,
                               java.lang.String event,
                               java.lang.String method)
Remove an event listener from the given client.

Parameters:
client - - the client that was being listened to
event - - the event the script was listening to
method - - the method that was invoked on the script when the event occurs

addServerEventListener

void addServerEventListener(java.lang.String event,
                            java.lang.String method)
Add an event listener to the server.

Parameters:
event - - the event the script wants to listen to
method - - the method that will be invoked on the script when the event occurs

removeServerEventListener

void removeServerEventListener(java.lang.String event,
                               java.lang.String method)
Remove an event listener from the server.

Parameters:
event - - the event the script was listening to
method - - the method that was invoked on the script when the event occurs


Copyright USER1 Subsystems Corporation - Tue Jan 28 2014, 05:05 PM -0500