Class SFSRoom
- All Implemented Interfaces:
Room
- Direct Known Subclasses:
MMORoom
The SmartFoxServer 3 client API doesn't know all of the Rooms existing on the server side, but only those that are joined by the user and those in the Room Groups that have been subscribed.
Subscribing to one or more Groups allows to listen to Room events for all Rooms belonging to that Group.
A list of available Rooms is created after a successful login and it is kept updated by the server.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected Stringprotected intprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected intprotected intprotected Stringprotected IRoomManagerprotected intprotected intprotected IUserManagerprotected Map<String, RoomVariable> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleancontainsUser(User user) Indicates whether the specified user is currently inside this Room or not.booleancontainsVariable(String name) Indicates whether this Room has the specified Room Variable set or not.booleanstatic RoomfromSFSArray(ISFSArray sfsa) intReturns the maximum amount of users, including spectators, that can be contained in this Room.Returns the Room Group name.intgetId()The id of this Room.intReturns the maximum number of spectators allowed in this Room (Game Rooms only).intReturns the maximum number of users allowed in this Room.getName()The unique name of this Room.Returns a list of User objects representing the players currently inside this Room (Game Rooms only).Returns a reference to the Room Manager which manages this Room.intReturns the current number of spectators in this Room (Game Rooms only).Returns a list of User objects representing the spectators currently inside this Room (Game Rooms only).getUserById(int id) Retrieves a User object from its id property.getUserByName(String name) Retrieves a User object from its name property.intReturns the current number of users in this Room.Returns a list of User objects representing all the users currently inside this Room.getVariable(String name) Retrieves a Room Variable from its name.Retrieves all the Room Variables of this Room.inthashCode()booleanIndicates whether audio streaming is allowed in the Room.booleanisGame()Indicates whether this is a Game Room or not.booleanisHidden()Indicates whether this Room is hidden or not.booleanisJoined()Indicates whether the client joined this Room or not.booleanbooleanIndicates whether this Room requires a password to be joined or not.voidremoveUser(User user) voidsetAudioStreamingAllowed(boolean value) voidsetGame(boolean game) voidsetHidden(boolean hidden) voidsetJoined(boolean joined) voidsetManaged(boolean managed) voidsetMaxSpectators(int maxSpectators) voidsetMaxUsers(int maxUsers) voidvoidsetPasswordProtected(boolean passwordProtected) voidsetRoomManager(IRoomManager manager) voidsetSpectatorCount(int spectatorCount) voidsetUserCount(int userCount) voidsetVariable(RoomVariable roomVariable) voidsetVariables(List<? extends RoomVariable> roomVariables) toString()Returns a string that contains the Room id, name and id of the Group to which it belongs.
-
Field Details
-
DEFAULT_GROUP_ID
- See Also:
-
id
protected int id -
name
-
groupId
-
isGame
protected boolean isGame -
isHidden
protected boolean isHidden -
isJoined
protected boolean isJoined -
isPasswordProtected
protected boolean isPasswordProtected -
isManaged
protected boolean isManaged -
isAudioStreamingAllowed
protected boolean isAudioStreamingAllowed -
variables
-
userManager
-
maxUsers
protected int maxUsers -
maxSpectators
protected int maxSpectators -
userCount
protected int userCount -
specCount
protected int specCount -
roomManager
-
-
Constructor Details
-
SFSRoom
-
SFSRoom
NOTE: never instantiate a SFSRoom manually: this is done by the SmartFoxServer 3 API internally.
-
-
Method Details
-
fromSFSArray
- Internal
-
getId
public int getId()Description copied from interface:RoomThe id of this Room. It is unique and it is generated by the server when the Room is created. -
getName
Description copied from interface:RoomThe unique name of this Room. Two Rooms in the same Zone can't have the same name (in a case sensitive way)NOTE: setting the name property manually has no effect on the server and can disrupt the API functioning. Use the ChangeRoomNameRequest request instead.
-
setName
-
getGroupId
Description copied from interface:RoomReturns the Room Group name. Each Group is identified by a unique string (its name or id) and it represents a different "container" for Rooms.Room Groups enable developers to organize Rooms under different types or categories and let clients select only those Groups they are interested in, in order to receive their events only. This is done via the SubscribeRoomGroupRequest and UnsubscribeRoomGroupRequest requests.
The default value is
default.- Specified by:
getGroupIdin interfaceRoom- See Also:
-
isJoined
public boolean isJoined()Description copied from interface:RoomIndicates whether the client joined this Room or not.NOTE: setting the isJoined property manually has no effect on the server and can disrupt the API functioning. Use the JoinRoomRequest request to join a new Room instead.
-
isGame
public boolean isGame()Description copied from interface:RoomIndicates whether this is a Game Room or not.NOTE: setting the isGame property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.
-
isHidden
public boolean isHidden()Description copied from interface:RoomIndicates whether this Room is hidden or not. This is a utility flag that can be used by developers to hide certain Rooms from the interface of their application.NOTE: setting the isHidden property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.
-
isPasswordProtected
public boolean isPasswordProtected()Description copied from interface:RoomIndicates whether this Room requires a password to be joined or not.NOTE: setting the isPasswordProtected property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room's password set when the Room is created or by means of the ChangeRoomPasswordStateRequest request.
- Specified by:
isPasswordProtectedin interfaceRoom- See Also:
-
setPasswordProtected
public void setPasswordProtected(boolean passwordProtected) - Specified by:
setPasswordProtectedin interfaceRoom- Internal
-
isManaged
public boolean isManaged() -
isAudioStreamingAllowed
public boolean isAudioStreamingAllowed()Description copied from interface:RoomIndicates whether audio streaming is allowed in the Room.- Specified by:
isAudioStreamingAllowedin interfaceRoom- Returns:
- true if streaming is allowed
-
setAudioStreamingAllowed
public void setAudioStreamingAllowed(boolean value) - Specified by:
setAudioStreamingAllowedin interfaceRoom- See Also:
-
getUserCount
public int getUserCount()Description copied from interface:RoomReturns the current number of users in this Room. In case of Game Rooms, this is the number of players.NOTE: setting the userCount property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.
- Specified by:
getUserCountin interfaceRoom
-
getMaxUsers
public int getMaxUsers()Description copied from interface:RoomReturns the maximum number of users allowed in this Room. In case of Game Rooms, this is the maximum number of players.NOTE: setting the maxUsers property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.
- Specified by:
getMaxUsersin interfaceRoom
-
getSpectatorCount
public int getSpectatorCount()Description copied from interface:RoomReturns the current number of spectators in this Room (Game Rooms only).NOTE: setting the spectatorCount property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.
- Specified by:
getSpectatorCountin interfaceRoom
-
getMaxSpectators
public int getMaxSpectators()Description copied from interface:RoomReturns the maximum number of spectators allowed in this Room (Game Rooms only).NOTE: setting the maxSpectators property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Game Room.
- Specified by:
getMaxSpectatorsin interfaceRoom
-
getCapacity
public int getCapacity()Description copied from interface:RoomReturns the maximum amount of users, including spectators, that can be contained in this Room.- Specified by:
getCapacityin interfaceRoom
-
setJoined
public void setJoined(boolean joined) -
setGame
public void setGame(boolean game) -
setHidden
public void setHidden(boolean hidden) -
setManaged
public void setManaged(boolean managed) - Specified by:
setManagedin interfaceRoom- Internal
-
setUserCount
public void setUserCount(int userCount) - Specified by:
setUserCountin interfaceRoom- Internal
-
setMaxUsers
public void setMaxUsers(int maxUsers) - Specified by:
setMaxUsersin interfaceRoom- Internal
-
setSpectatorCount
public void setSpectatorCount(int spectatorCount) - Specified by:
setSpectatorCountin interfaceRoom- Internal
-
setMaxSpectators
public void setMaxSpectators(int maxSpectators) - Specified by:
setMaxSpectatorsin interfaceRoom- Internal
-
addUser
-
removeUser
- Specified by:
removeUserin interfaceRoom- Internal
-
containsUser
Description copied from interface:RoomIndicates whether the specified user is currently inside this Room or not.- Specified by:
containsUserin interfaceRoom- Parameters:
user- The User object representing the user whose presence in this Room must be checked.- Returns:
trueif the user is inside this Room;falseotherwise.
-
getUserByName
Description copied from interface:RoomRetrieves a User object from its name property.- Specified by:
getUserByNamein interfaceRoom- Parameters:
name- The name of the user to be found.- Returns:
- The User object representing the user, or
nullif no user with the passed name exists in this Room. - See Also:
-
getUserById
Description copied from interface:RoomRetrieves a User object from its id property.- Specified by:
getUserByIdin interfaceRoom- Parameters:
id- The id of the user to be found.- Returns:
- The User object representing the user, or
nullif no user with the passed id exists in this Room. - See Also:
-
getUserList
Description copied from interface:RoomReturns a list of User objects representing all the users currently inside this Room.- Specified by:
getUserListin interfaceRoom
-
getPlayerList
Description copied from interface:RoomReturns a list of User objects representing the players currently inside this Room (Game Rooms only).- Specified by:
getPlayerListin interfaceRoom
-
getSpectatorList
Description copied from interface:RoomReturns a list of User objects representing the spectators currently inside this Room (Game Rooms only).- Specified by:
getSpectatorListin interfaceRoom
-
getVariable
Description copied from interface:RoomRetrieves a Room Variable from its name.- Specified by:
getVariablein interfaceRoom- Parameters:
name- The name of the Room Variable to be retrieved.- Returns:
- The RoomVariable object representing the Room Variable, or
nullif no Room Variable with the passed name exists in this Room. - See Also:
-
getVariables
Description copied from interface:RoomRetrieves all the Room Variables of this Room.- Specified by:
getVariablesin interfaceRoom- Returns:
- The list of RoomVariable objects associated with this Room.
- See Also:
-
setVariable
- Specified by:
setVariablein interfaceRoom- Internal
-
setVariables
- Specified by:
setVariablesin interfaceRoom- Internal
-
containsVariable
Description copied from interface:RoomIndicates whether this Room has the specified Room Variable set or not.- Specified by:
containsVariablein interfaceRoom- Parameters:
name- The name of the Room Variable whose existance in this Room must be checked.- Returns:
trueif a Room Variable with the passed name exists in this Room.
-
getRoomManager
Description copied from interface:RoomReturns a reference to the Room Manager which manages this Room.NOTE: setting the roomManager property manually has no effect on the server and can disrupt the API functioning.
- Specified by:
getRoomManagerin interfaceRoom
-
setRoomManager
- Specified by:
setRoomManagerin interfaceRoom- Throws:
SFSException- Internal
-
equals
-
hashCode
public int hashCode() -
toString
Returns a string that contains the Room id, name and id of the Group to which it belongs.
-