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
Modifier and TypeMethodDescriptionvoid
addClientEventListener
(Client client, String event, String method) Add a client event listener to the given room.void
addRoomEventListener
(String event, String method) Add a room event listener to the room to which the room module script is attached.void
addRoomEventListener
(Room room, String event, String method) Add a room event listener to the given room.void
addServerEventListener
(String event, String method) Add an event listener to the server.void
removeClientEventListener
(Client client, String event, String method) Remove an event listener from the given client.void
removeRoomEventListener
(String event, String method) Remove an event listener from the room to which the room module script is attached.void
removeRoomEventListener
(Room room, String event, String method) Remove an event listener from the given room.void
removeServerEventListener
(String event, String method) Remove an event listener from the server.
-
Method Details
-
addRoomEventListener
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 tomethod
- - the method that will be invoked on the script when the event occurs
-
removeRoomEventListener
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 tomethod
- - the method that was invoked on the script when the event occurs
-
addRoomEventListener
Add a room event listener to the given room.- Parameters:
room
- - the room to listen to for the event occurringevent
- - the event the script wants to listen tomethod
- - the method that will be invoked on the script when the event occurs
-
removeRoomEventListener
-
addClientEventListener
Add a client event listener to the given room.- Parameters:
client
- - the room to listen to for the event occurringevent
- - the event the script wants to listen tomethod
- - the method that will be invoked on the script when the event occurs
-
removeClientEventListener
Remove an event listener from the given client.- Parameters:
client
- - the client that was being listened toevent
- - the event the script was listening tomethod
- - the method that was invoked on the script when the event occurs
-
addServerEventListener
-
removeServerEventListener
-