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 Details

    • addRoomEventListener

      void addRoomEventListener(String event, 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(String event, 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, String event, 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, String event, 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, String event, 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, String event, 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(String event, 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(String event, 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