|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.smartfoxserver.v2.entities.SFSRoom
public class SFSRoom
Each Room can contain any number of Users and can be organized in Room Groups. A Group is nothing more than a unique String ID that is assigned to each Room. By assigning different Group IDs to different Rooms you will be able to separate Rooms in different "departments" avoiding to mix all Rooms together, especially when the application will create thousands of Rooms.
An example of grouping Rooms is separating the lobby Rooms from the chat and game Rooms. You could define three different groups called "Lobby", "Chat", "Game" and assign your Rooms to one of these groups at the time of the Room creation.
Also each Room provides a number of essential services:
User,
SFSGame,
SFSApi,
BaseSFSExtension,
SFSExtension| Field Summary | |
|---|---|
protected org.slf4j.Logger |
logger
|
| Constructor Summary | |
|---|---|
SFSRoom(java.lang.String name)
|
|
SFSRoom(java.lang.String name,
java.lang.Class<?> customPlayerIdGeneratorClass)
|
|
| Method Summary | |
|---|---|
void |
addUser(User user)
|
void |
addUser(User user,
boolean asSpectator)
|
boolean |
containsProperty(java.lang.Object key)
|
boolean |
containsUser(java.lang.String name)
Checks if the specified User is joined in the Room |
boolean |
containsUser(User user)
Checks if the specified User is joined in the Room |
boolean |
containsVariable(java.lang.String varName)
Checks if a certain Room Variable name exists |
boolean |
equals(java.lang.Object obj)
|
com.smartfoxserver.v2.util.IAdminHelper |
getAdminHelper()
|
SFSRoomRemoveMode |
getAutoRemoveMode()
Return the auto-remove mode of the Room |
int |
getCapacity()
Return the capacity of the Room (maximum number of clients that can be contained). |
java.lang.String |
getDump()
Get a dump of all Room attributes/settings. |
ISFSExtension |
getExtension()
Get the extension connected to this Room, if any |
java.lang.String |
getGroupId()
Get the Room Group Id. |
int |
getId()
Return the unique Room Id |
long |
getLifeTime()
Obtain the time of existence of the Room |
int |
getMaxRoomVariablesAllowed()
Return the maximum number of Room Variables allowed in the Room. |
int |
getMaxSpectators()
Return the maximum number of Spectators allowed in the Room. |
int |
getMaxUsers()
Return the maximum number of Users allowed in the Room. |
java.lang.String |
getName()
Get the room name |
User |
getOwner()
Get the owner of the Room (the user that created it) |
java.lang.String |
getPassword()
Get the Room password. |
java.util.List<User> |
getPlayersList()
For Game Rooms: get all Players in the Room (same as all User without the Spectators) |
java.lang.Object |
getProperty(java.lang.Object key)
|
ISFSArray |
getRoomVariablesData(boolean globalsOnly)
|
java.util.List<ISession> |
getSessionList()
Get all the User Sessions in the Room |
RoomSize |
getSize()
Return the current Room size |
java.util.List<User> |
getSpectatorsList()
For Game Rooms: get all Spectators in the Room (same as all User without the Players) |
User |
getUserById(int id)
|
User |
getUserByName(java.lang.String name)
|
User |
getUserByPlayerId(int playerId)
Get the User currently having the specified playerId (Game Room only) |
User |
getUserBySession(ISession session)
|
java.util.List<User> |
getUserList()
Get all Users in the Room |
ISFSArray |
getUserListData()
|
com.smartfoxserver.v2.entities.managers.IUserManager |
getUserManager()
|
RoomVariable |
getVariable(java.lang.String varName)
Get a Room Variable |
java.util.List<RoomVariable> |
getVariables()
Get the full list of Room Variables in the Room |
int |
getVariablesCount()
Get the total amount of Room Variables for this Room |
java.util.List<RoomVariable> |
getVariablesCreatedByUser(User user)
Get a list of Room Variables created by a specific User |
Zone |
getZone()
Get the Zone managing this Room. |
boolean |
isActive()
Return true if the Room is active in the Zone. |
boolean |
isDynamic()
Checks if the Room was created dynamically (at runtime) |
boolean |
isEmpty()
Checks whether the Room is empty |
boolean |
isFlagSet(SFSRoomSettings flag)
Checks whether a certain Room Setting is set |
boolean |
isFull()
Checks whether the Room is full. |
boolean |
isGame()
Checks if this is a Game Room |
boolean |
isHidden()
Checks if the Game is hidden. |
boolean |
isPasswordProtected()
Checks if the Room requires a password for joining it |
boolean |
isPublic()
Returns true if the Room has public access, in other words it doesn't require a password. |
boolean |
isUseWordsFilter()
Check if the word filter is used in this Room (applied to Public Messages) |
void |
removeProperty(java.lang.Object key)
|
void |
removeUser(User user)
|
void |
removeVariable(java.lang.String varName)
|
java.util.List<RoomVariable> |
removeVariablesCreatedByUser(User user)
|
void |
setActive(boolean flag)
|
void |
setAdminHelper(com.smartfoxserver.v2.util.IAdminHelper helper)
|
void |
setAutoRemoveMode(SFSRoomRemoveMode autoRemoveMode)
|
void |
setCapacity(int maxUser,
int maxSpectators)
|
void |
setDynamic(boolean dynamic)
|
void |
setExtension(ISFSExtension extension)
|
void |
setFlag(SFSRoomSettings flag,
boolean state)
|
void |
setFlags(java.util.Set<SFSRoomSettings> settings)
|
void |
setGame(boolean game)
|
void |
setGame(boolean game,
java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
|
void |
setGroupId(java.lang.String groupId)
|
void |
setHidden(boolean hidden)
|
void |
setMaxRoomVariablesAllowed(int max)
|
void |
setMaxSpectators(int maxSpectators)
|
void |
setMaxUsers(int maxUsers)
|
void |
setName(java.lang.String name)
|
void |
setOwner(User owner)
|
void |
setPassword(java.lang.String password)
|
void |
setProperty(java.lang.Object key,
java.lang.Object value)
|
void |
setUserManager(com.smartfoxserver.v2.entities.managers.IUserManager userManager)
|
void |
setUseWordsFilter(boolean useWordsFilter)
Toggle the word filter in this Room (applied to Public Messages) |
void |
setVariable(RoomVariable roomVariable)
|
void |
setVariable(RoomVariable roomVariable,
boolean overrideOwnership)
|
void |
setVariables(java.util.List<RoomVariable> variables)
|
void |
setVariables(java.util.List<RoomVariable> variables,
boolean overrideOwnership)
|
void |
setZone(Zone zone)
|
void |
switchPlayerToSpectator(User user)
|
void |
switchSpectatorToPlayer(User user)
|
ISFSArray |
toSFSArray(boolean globalRoomVarsOnly)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected org.slf4j.Logger logger
| Constructor Detail |
|---|
public SFSRoom(java.lang.String name)
public SFSRoom(java.lang.String name,
java.lang.Class<?> customPlayerIdGeneratorClass)
| Method Detail |
|---|
public int getId()
getId in interface Roompublic java.lang.String getGroupId()
getGroupId in interface Roompublic void setGroupId(java.lang.String groupId)
setGroupId in interface Roompublic java.lang.String getName()
getName in interface Roompublic void setName(java.lang.String name)
setName in interface Roompublic java.lang.String getPassword()
getPassword in interface RoomRoom.isPasswordProtected()public void setPassword(java.lang.String password)
setPassword in interface Roompublic boolean isPasswordProtected()
isPasswordProtected in interface Roompublic boolean isPublic()
isPublic in interface Roompublic int getMaxUsers()
getMaxUsers in interface Roompublic void setMaxUsers(int maxUsers)
setMaxUsers in interface Roompublic int getMaxSpectators()
getMaxSpectators in interface Roompublic void setMaxSpectators(int maxSpectators)
setMaxSpectators in interface Roompublic User getOwner()
getOwner in interface Roompublic void setOwner(User owner)
setOwner in interface Roompublic com.smartfoxserver.v2.entities.managers.IUserManager getUserManager()
getUserManager in interface Roompublic void setUserManager(com.smartfoxserver.v2.entities.managers.IUserManager userManager)
setUserManager in interface Roompublic Zone getZone()
getZone in interface Roompublic void setZone(Zone zone)
setZone in interface Roompublic boolean isDynamic()
isDynamic in interface Roompublic void setDynamic(boolean dynamic)
setDynamic in interface Roompublic boolean isGame()
isGame in interface Room
public void setGame(boolean game,
java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
setGame in interface Roompublic void setGame(boolean game)
setGame in interface Roompublic boolean isHidden()
isHidden in interface Roompublic void setHidden(boolean hidden)
setHidden in interface Roompublic boolean isActive()
isActive in interface Roompublic void setActive(boolean flag)
setActive in interface Roompublic SFSRoomRemoveMode getAutoRemoveMode()
getAutoRemoveMode in interface RoomSFSRoomRemoveModepublic void setAutoRemoveMode(SFSRoomRemoveMode autoRemoveMode)
setAutoRemoveMode in interface Roompublic java.util.List<User> getPlayersList()
getPlayersList in interface Roompublic java.lang.Object getProperty(java.lang.Object key)
getProperty in interface Roompublic RoomSize getSize()
getSize in interface RoomRoomSizepublic void removeProperty(java.lang.Object key)
removeProperty in interface Roompublic java.util.List<User> getSpectatorsList()
getSpectatorsList in interface Roompublic User getUserById(int id)
getUserById in interface Roomid - the User id
public User getUserByName(java.lang.String name)
getUserByName in interface Roomname - the User name
public User getUserBySession(ISession session)
getUserBySession in interface Roomsession - the User session
public User getUserByPlayerId(int playerId)
getUserByPlayerId in interface RoomplayerId - the player id
public java.util.List<User> getUserList()
getUserList in interface Roompublic java.util.List<ISession> getSessionList()
getSessionList in interface Roompublic int getVariablesCount()
getVariablesCount in interface Roompublic RoomVariable getVariable(java.lang.String varName)
getVariable in interface RoomvarName - the name of the variable
SFSRoomVariablepublic java.util.List<RoomVariable> getVariables()
getVariables in interface Roompublic java.util.List<RoomVariable> getVariablesCreatedByUser(User user)
getVariablesCreatedByUser in interface Roomuser - the User
public boolean containsProperty(java.lang.Object key)
containsProperty in interface Roompublic void removeVariable(java.lang.String varName)
removeVariable in interface Roompublic java.util.List<RoomVariable> removeVariablesCreatedByUser(User user)
removeVariablesCreatedByUser in interface Roompublic int getCapacity()
getCapacity in interface Room
public void setCapacity(int maxUser,
int maxSpectators)
setCapacity in interface Roompublic void setMaxRoomVariablesAllowed(int max)
setMaxRoomVariablesAllowed in interface Roompublic int getMaxRoomVariablesAllowed()
getMaxRoomVariablesAllowed in interface Roompublic void setFlags(java.util.Set<SFSRoomSettings> settings)
setFlags in interface Roompublic boolean isFlagSet(SFSRoomSettings flag)
isFlagSet in interface Roomflag - the flag
SFSRoomSettings
public void setFlag(SFSRoomSettings flag,
boolean state)
setFlag in interface Roompublic boolean isUseWordsFilter()
isUseWordsFilter in interface Roompublic void setUseWordsFilter(boolean useWordsFilter)
setUseWordsFilter in interface Room
public void setProperty(java.lang.Object key,
java.lang.Object value)
setProperty in interface Roompublic void setVariables(java.util.List<RoomVariable> variables)
setVariables in interface Room
public void setVariables(java.util.List<RoomVariable> variables,
boolean overrideOwnership)
setVariables in interface Room
public void setVariable(RoomVariable roomVariable)
throws SFSVariableException
setVariable in interface RoomSFSVariableException
public void setVariable(RoomVariable roomVariable,
boolean overrideOwnership)
throws SFSVariableException
setVariable in interface RoomSFSVariableExceptionpublic boolean containsVariable(java.lang.String varName)
containsVariable in interface RoomvarName - the variable name
public boolean containsUser(java.lang.String name)
containsUser in interface Roomname - the User name
public boolean containsUser(User user)
containsUser in interface Roomuser - the User
public void addUser(User user)
throws SFSJoinRoomException
addUser in interface RoomSFSJoinRoomException
public void addUser(User user,
boolean asSpectator)
throws SFSJoinRoomException
addUser in interface RoomSFSJoinRoomExceptionpublic void removeUser(User user)
removeUser in interface Room
public void switchPlayerToSpectator(User user)
throws SFSRoomException
switchPlayerToSpectator in interface RoomSFSRoomException
public void switchSpectatorToPlayer(User user)
throws SFSRoomException
switchSpectatorToPlayer in interface RoomSFSRoomExceptionpublic long getLifeTime()
getLifeTime in interface Roompublic boolean isEmpty()
isEmpty in interface Roompublic boolean isFull()
isFull in interface Roompublic ISFSArray getUserListData()
getUserListData in interface Roompublic ISFSArray getRoomVariablesData(boolean globalsOnly)
getRoomVariablesData in interface Roompublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic ISFSExtension getExtension()
getExtension in interface Roompublic void setExtension(ISFSExtension extension)
setExtension in interface Roompublic ISFSArray toSFSArray(boolean globalRoomVarsOnly)
toSFSArray in interface Roompublic java.lang.String getDump()
getDump in interface Roompublic com.smartfoxserver.v2.util.IAdminHelper getAdminHelper()
public void setAdminHelper(com.smartfoxserver.v2.util.IAdminHelper helper)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||