interfaces

AppWarp S2 component’s implement interfaces through developers server side applications can access their functionality.

AppWarpServer

/**
* Starts the AppWarp server instance. This sets up the networking and starts 
* accepting client connections and messages. The server must be started before you
* can use the admin dashboard.
* @param adaptor is your object which extends the BaseServerAdaptor class
* @param configPath is the path to your AppConfig.json file.
* @return 
*/
public static boolean start(BaseServerAdaptor adaptor, String configPath)

IZone

/**
* sets the event adaptor for the zone
* 
* @param adaptor the adaptor to be set
*/
public void setAdaptor(BaseZoneAdaptor adaptor);

/**
* 
* @return collection of rooms in the zone
*/
public Collection<IRoom> getRooms();

/**
* 
* @return collection of users in the zone
*/
public Collection<IUser> getUsers();

/**
* remove a user from the zone. the user will get disconnected from the server.
* 
* @param user the user to be removed
*/
public void removeUser(IUser user);

/**
* creates and adds a new room to the zone
* 
* @param name the name of the room
* @param maxUsers the max users allowed in the room
* @param properties properties added to the room
* 
* @return the room created
*/
public IRoom createRoom(String name, int maxUsers, HashMap<String, Object> properties);

/**
* creates and adds a new turn based room to the zone
* 
* @param name the name of the room
* @param maxUsers the max users allowed in the room
* @param properties properties added to the room
* @param turnTime turn time in seconds for each user's turn
* 
* @return the turn based room created
*/
public ITurnBasedRoom createTurnRoom(String name, int maxUsers, HashMap<String, Object> properties, int turnTime);

/**
* deletes and removes a room from the zone
* 
* @param roomId the id of the room to be removed.
* 
* @return true indicates that the room was successfully deleted.
*/
public boolean deleteRoom(String roomId);

/**
* 
* @return the name of the application represented by the zone
*/
public String getName();

/**
* 
* @return the appkey of the zone
*/
public String getAppKey();

/**
* 
* @return the secret of the zone
*/
public String getSecret();

/**
* Sends back to the user a response for its pending connect request. Useful for 
* asynchronous custom user authentication scenario.
* @param user
* @param result
* @param description
* @return true if successful
*/
public void sendAddUserResponse(IUser user, byte result, String description);

IRoom

/**
* Sends a update peers event to all the subscribers in the room
* 
* @param update the byte array to send
* @param udp whether to send the update over udp if possible
*/
public void BroadcastUpdatePeers(byte[] update, boolean udp);       

/**
* Send a chat notification event to all the subscribers of the room
* 
* @param sender the name of the sender in the chat event broadcast
* @param message the message to be sent
*/
public void BroadcastChat(String sender, String message);  

/**
* gets a list of users joined in the room
* 
* @return 
*/
public List<IUser> getJoinedUsers();

/**
* gets a list of users subscribed to the room
* 
* @return 
*/
public List<IUser> getSubscribedUsers();

/**
* gets the name of the room
* @return 
*/
public String getName();

/**
* gets the unique id of the room
* @return 
*/
public String getId();

/**
* gets the max users allowed in the room
* 
* @return 
*/
public int getMaxUsers();

/**
* remove a user from the room
* 
* @param user the user to be removed
* @param sendNotification whether to send a user left room notification to
* subscribers of the room
* @return 
*/
public boolean removeUser(IUser user, boolean sendNotification);

/**
* remove a users subscription. The user will not receive any notifications 
* from the room after this.
* 
* @param user the user to be removed from subscribers list
* @return 
*/
public boolean removeSubscriber(IUser user);

/**
* set the event adaptor of the room
* 
* @param adaptor the adaptor to be set
*/
public void setAdaptor(BaseRoomAdaptor adaptor);

/**
* add a user to the room's joined users list. the user will be removed from its
* current location if any.
* 
* @param user the user to be added
* @param sendNotification whether to send a user joined notification
* 
* @return true if added successfully
*/
public boolean addUser(IUser user, boolean sendNotification);

/**
* 
* @return true if the room is a static room
*/
public boolean isAdmin();

/**
* 
* @return true if the room is a turn based room
*/
public boolean isTurnBased();   

/**
* 
* @return the current room event adaptor of the room
*/
public BaseRoomAdaptor getAdaptor();    

/**
* returns the properties map of the room
* @return 
*/
public HashMap<String,Object> getProperties();

/**
* returns the property locks held by users
* @return 
*/    
public HashMap<String,IUser> getPropertyLocks();

/**
* Resets the properties and the locks held.
* If successful, it will also broadcast the property change notification
* to all the subscribed clients i.e. onUserChangeRoomProperty with an empty
* sender name. 
*
* @param properties the new properties of the room
* @param locks the new locks assigned per user (use Empty map instead of NULL)
* @return true if successful
*/
public boolean resetPropertiesAndLockMaps(HashMap<String,Object> properties, HashMap<String, IUser> locks);

ITurnBasedRoom

/**
* 
* @return the user whose turn it is running 
* if the room is started.
*/
public IUser getTurnUser();

/**
* 
* @return the user whose turn will be next
* if the room is started.
*/
public IUser getNextTurnUser();

/**
* Update the turn to the specified user and sends a move completed notification
* event to the subscribers of the turn room. The user must be a user who is
* joined in the room.
* 
* @param nextTurn the user whose turn is next
* @param moveData the move data sent in the event
* @param sender the name of the sender of the event
* 
* @return true if sent successfully
*/
public boolean sendMoveUpdate(IUser nextTurn, String moveData, String sender);

/**
* updates the turn to a given user.
* 
* @param nextTurn the user whose turn it is now.
* 
* @return true if set successfully
*/
public boolean setNextTurn(IUser nextTurn);

/**
* updates the time (in seconds) for the turn
* @param seconds 
*/
public void setTurnTime(int seconds);

/**
* 
* @return gets the current time allowed for a turn before its expired
*/
public int getTurnTime();

/**
* updates the state of the game to started and sends a game started notification 
* to all the subscribers of the room.
* 
* @param senderName the sender name sent in the game started notification
* @return true if successful
*/
public boolean startGame(String senderName);    

/**
* updates the state of the game to stopped and sends a game stopped notification 
* to all the subscribers of the room.
* 
* @param senderName the sender name sent in the game stopped notification
* @return true if successful
*/
public boolean stopGame(String senderName);

/**
* 
* @return true if the game is in started state (active)
*/
public boolean isGameStarted();

/**
* 
* @return time in milliseconds remaining before the current turn expires
*/
public long getCurrentTurnTimeRemaining();

IUser

/**
* 
* @return true if the user is currently paused
*/
public boolean isPaused();

/**
* 
* @return the current location of the user
*/
public IRoom getLocation();

/**
* 
* @return the name of the user sent in the connect request
*/
public String getName();

/**
* sets the custom data associated with the user
* 
* @param data the data
*/
public void setCustomData(String data);

/**
* 
* @return the custom data associated with the user
*/
public String getCustomData();

/**
* sends an update peers notification to the user
* 
* @param update the byte array update to be sent
* @param isUDP whether to send the message over udp if possible
*/
public void SendUpdatePeersNotification(byte[] update, boolean isUDP);

/**
* sends a chat notification event to the user
* 
* @param sender the name of the sender of the event
* @param message the message to be sent
* @param inRoom the room associated with the chat event
*/    
public void SendChatNotification(String sender, String message, IRoom inRoom);

/**
* Useful for building geo based scenarios or analytics. Returns a valid
* value if the user is currently in connected state (not paused and not removed).
* 
* @return the IP address string in textual presentation.
*/
public String getIPAddress();