com.electrotank.electroserver4.extensions.api
Interface PluginApi

All Superinterfaces:
ElectroServerApi
All Known Implementing Classes:
PluginApiImpl

public interface PluginApi
extends ElectroServerApi

The api for a plug-in.

A plug-in is the most generic and flexible way to add functionality to ElectroServer. Simply put, a plug-in is a piece of code that can be tied to the server itself or a room and can then be called via clients to directly ask it to perform an action. As a special case, room-level plug-ins have the ability to listen to many events that occur in a room such as room variable changes or public messages. These are the bread and butter of multi-player game development.

See Also:
Plugin, BasePlugin, ElectroServerApi

Method Summary
 EsObject getGameDetails()
          Gets the game details as an EsObject.
 int getRoomId()
          Gets the roomId.
 String getRoomName()
          Gets the name of the room.
 EsObject getUserEsObject(String userName)
          Looks up the EsObject for a given userName.
 Object getUserPluginVariable(String userName, Object name)
          Looks up the plug-in variable for a given user.
 Collection<String> getUsers()
          Gets a Collection of user names.
 int getZoneId()
          Gets the zoneId.
 String getZoneName()
          Gets the name of the zone.
 boolean isGameHidden()
          Is this game hidden?
 boolean isGameLocked()
          Is this game locked?
 boolean isGameRoom()
          Is the room for this plug-in a game?
 boolean isRoomLevel()
          True if the plug-in is a room-level plug-in
 boolean isServerLevel()
          True if the plug-in is a server-level plug-in.
 void pauseQueue()
          Pauses the queue of messages.
 Object removeUserPluginVariable(String userName, Object name)
          Removes the specified plug-in variable for this user.
 void resumeQueue()
          Resumes the queue of messages.
 void sendQueuedPluginMessageToRoom(EsObjectRO variable)
          Adds the given message to the message queue of each user in the room.
 void sendQueuedPluginMessageToRoom(String messageName, EsObjectRO variable)
          Adds the given message to the message queue of each user in the room.
 void sendQueuedPluginMessageToUser(String userName, EsObjectRO variable)
          Adds the given message to the message queue of the specified user.
 void sendQueuedPluginMessageToUser(String name, String userName, EsObjectRO variable)
          Adds the given message to the message queue of the specified user.
 void sendQueuedPluginMessageToUsers(Collection<String> userNames, EsObjectRO variable)
          Adds the given message to the message queue of each user in the Collection.
 void sendQueuedPluginMessageToUsers(String messageName, Collection<String> userNames, EsObjectRO variable)
          Adds the given message to the message queue of each user in the Collection.
 void setGameDetails(EsObject gameDetails)
          Sets the game details.
 void setGameHiddenState(boolean newHiddenValue)
          Sets the game state to hidden or not.
 void setGameLockState(boolean newLockValue)
          Sets the game state to locked or not.
 void setUserPluginVariable(String userName, Object name, Object value)
          Sets the specified plug-in variable for a given user.
 void startQueue(long frequency)
          Starts the queue of messages.
 void stopQueue()
          Stops the queue of messages.
 
Methods inherited from interface com.electrotank.electroserver4.extensions.api.ElectroServerApi
acquireManagedObject, addBuddy, addUsersToRoom, addUsersToRoom, applyLanguageFilterToString, banUserFromRoom, blockAndCallUrl, callRoomPlugin, callServerPlugin, callUrl, callUrlFromScript, cancelScheduledExecution, createGameForUsers, createGameForUsers, createOrUpdateUserVariable, createRoom, createRoom, createRoomInNamedZone, createRoomInNamedZone, createRoomVariable, createRoomVariableForUser, deleteExtensionBoundUserServerVariable, deleteRoomVariable, deleteUserServerVariable, deleteUserVariable, destroyRoom, getExtensionBoundUserServerVariable, getExtensionName, getFileSystemApi, getHandle, getLogger, getName, getRoomPlugin, getRoomsInZone, getRoomsInZoneByName, getRoomVariable, getRoomVariables, getServerPlugin, getUser, getUserServerVariable, getUsersInRoom, getUserVariable, getUserVariables, getZones, isUserLoggedIn, kickUserFromRoom, kickUserFromServer, registerGameConfiguration, releaseManagedObject, removeBuddy, scheduleExecution, scheduleExecutionFromScript, sendPluginMessageToRoom, sendPluginMessageToRooms, sendPluginMessageToServer, sendPluginMessageToUser, sendPluginMessageToUsers, sendPluginMessageToUsers, sendPluginMessageToZone, sendPluginMessageToZones, sendPluginMessageToZones, setExtensionBoundUserServerVariable, setUserServerVariable, updateRoomVariable
 

Method Detail

getUsers

Collection<String> getUsers()
Gets a Collection of user names.

Returns:
Collection of user names

isRoomLevel

boolean isRoomLevel()
True if the plug-in is a room-level plug-in

Returns:
true if the plug-in is a room-level plug-in

isServerLevel

boolean isServerLevel()
True if the plug-in is a server-level plug-in.

Returns:
true if the plug-in is a server-level plug-in

getRoomName

String getRoomName()
Gets the name of the room.

Returns:
name of the room

getRoomId

int getRoomId()
Gets the roomId.

Returns:
roomId

getZoneName

String getZoneName()
Gets the name of the zone.

Returns:
name of the zone

getZoneId

int getZoneId()
Gets the zoneId.

Returns:
zoneId

getUserPluginVariable

Object getUserPluginVariable(String userName,
                             Object name)
Looks up the plug-in variable for a given user.

Parameters:
userName - name of the user
name - name of the plug-in variable
Returns:
plug-in variable
See Also:
setUserPluginVariable, removeUserPluginVariable

setUserPluginVariable

void setUserPluginVariable(String userName,
                           Object name,
                           Object value)
Sets the specified plug-in variable for a given user.

Parameters:
userName - name of the user
name - name of the plug-in variable to set
value - new value of the plug-in variable
See Also:
getUserPluginVariable, removeUserPluginVariable

removeUserPluginVariable

Object removeUserPluginVariable(String userName,
                                Object name)
Removes the specified plug-in variable for this user.

Parameters:
userName - name of the user
name - name of the variable to remove
Returns:
the value of the variable removed, if found
See Also:
getUserPluginVariable, setUserPluginVariable

getUserEsObject

EsObject getUserEsObject(String userName)
Looks up the EsObject for a given userName.

Parameters:
userName - name of the user
Returns:
esObject
See Also:
EsObject

isGameRoom

boolean isGameRoom()
Is the room for this plug-in a game?

Returns:
true if this is a game

isGameHidden

boolean isGameHidden()
Is this game hidden?

Returns:
true if the game is hidden.
See Also:
setGameHiddenState

isGameLocked

boolean isGameLocked()
Is this game locked?

Returns:
true if the game is locked.
See Also:
setGameLockState

getGameDetails

EsObject getGameDetails()
Gets the game details as an EsObject.

Returns:
gameDetails
See Also:
setGameDetails, EsObject

setGameDetails

void setGameDetails(EsObject gameDetails)
Sets the game details.

Parameters:
gameDetails - EsObject with the new value for gameDetails
See Also:
getGameDetails, EsObject

setGameHiddenState

void setGameHiddenState(boolean newHiddenValue)
Sets the game state to hidden or not.

Parameters:
newHiddenValue - true if game will now be hidden.
See Also:
isGameHidden

setGameLockState

void setGameLockState(boolean newLockValue)
Sets the game state to locked or not.

Parameters:
newLockValue - true if the game will now be locked.
See Also:
isGameLocked

startQueue

void startQueue(long frequency)
Starts the queue of messages. A queue is used to aggregate messages, so that several can be sent at once. This is more efficient if there are a lot of messages to be sent in a very short period of time, but results in a delay of the first message.

Parameters:
frequency - scheduling rate in milliseconds
See Also:
stopQueue, pauseQueue, resumeQueue

stopQueue

void stopQueue()
Stops the queue of messages. Cancels scheduled (future) messages.

See Also:
startQueue, pauseQueue, resumeQueue

pauseQueue

void pauseQueue()
Pauses the queue of messages.

See Also:
startQueue, stopQueue, resumeQueue

resumeQueue

void resumeQueue()
Resumes the queue of messages.

See Also:
startQueue, stopQueue, pauseQueue

sendQueuedPluginMessageToRoom

void sendQueuedPluginMessageToRoom(EsObjectRO variable)
Adds the given message to the message queue of each user in the room.

Parameters:
variable - unnamed message
See Also:
sendQueuedPluginMessageToUser, sendQueuedPluginMessageToUsers

sendQueuedPluginMessageToRoom

void sendQueuedPluginMessageToRoom(String messageName,
                                   EsObjectRO variable)
Adds the given message to the message queue of each user in the room. A queue is used to aggregate messages, so that several can be sent at once. This is more efficient if there are a lot of messages to be sent in a very short period of time, but results in a delay of the first message.

Parameters:
messageName - name of the message
variable - message
See Also:
sendQueuedPluginMessageToUser, sendQueuedPluginMessageToUsers

sendQueuedPluginMessageToUser

void sendQueuedPluginMessageToUser(String userName,
                                   EsObjectRO variable)
Adds the given message to the message queue of the specified user.

Parameters:
userName - name of the user
variable - unnamed message
See Also:
sendQueuedPluginMessageToRoom, sendQueuedPluginMessageToUsers

sendQueuedPluginMessageToUser

void sendQueuedPluginMessageToUser(String name,
                                   String userName,
                                   EsObjectRO variable)
Adds the given message to the message queue of the specified user.

Parameters:
name - name of the message
userName - name of the user
variable - message
See Also:
sendQueuedPluginMessageToRoom, sendQueuedPluginMessageToUsers

sendQueuedPluginMessageToUsers

void sendQueuedPluginMessageToUsers(Collection<String> userNames,
                                    EsObjectRO variable)
Adds the given message to the message queue of each user in the Collection.

Parameters:
userNames - Collection of names of users
variable - unnamed message
See Also:
sendQueuedPluginMessageToRoom, sendQueuedPluginMessageToUser

sendQueuedPluginMessageToUsers

void sendQueuedPluginMessageToUsers(String messageName,
                                    Collection<String> userNames,
                                    EsObjectRO variable)
Adds the given message to the message queue of each user in the Collection.

Parameters:
messageName - name of the message
userNames - Collection of names of users
variable - message
See Also:
sendQueuedPluginMessageToRoom, sendQueuedPluginMessageToUser


Copyright © 2007 Electrotank, Inc. All Rights Reserved.