|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsfs2x.client.entities.SFSRoom
public class SFSRoom
The SFSRoom object represents a SmartFoxServer Room entity on the client.
The SmartFoxServer 2X client API are not aware of all the Rooms which exist on the server side, but only of those that are joined by the user and those in the Room Groups that have been subscribed. Subscribing to one or more Groups allows the client to listen to Room events in specific "areas" of the Zone, without having to retrieve and keep synchronized the details of all available Rooms, thus reducing the traffic between the client and the server considerably.
The list of available Rooms is created after a successful login and it is kept updated continuously by the server.
CreateRoomRequest,
JoinRoomRequest,
SubscribeRoomGroupRequest,
UnsubscribeRoomGroupRequest,
ChangeRoomNameRequest,
ChangeRoomPasswordStateRequest,
ChangeRoomCapacityRequest,
SmartFox.roomManager| Constructor Summary | |
|---|---|
SFSRoom(int id,
java.lang.String name)
|
|
SFSRoom(int id,
java.lang.String name,
java.lang.String groupId)
Creates a new SFSRoom instance. |
|
| Method Summary | |
|---|---|
void |
addUser(User user)
*Private* |
boolean |
containsUser(User user)
*Private* |
boolean |
containsVariable(java.lang.String name)
Indicates whether this Room has the specified Room Variable set or not. |
static Room |
fromSFSArray(com.smartfoxserver.v2.entities.data.ISFSArray sfsa)
*Private* |
int |
getCapacity()
Returns the maximum amount of users, including spectators, that can be contained in this Room. |
java.lang.String |
getGroupId()
Returns the Room Group name. |
int |
getId()
Indicates the id of this Room. |
int |
getMaxSpectators()
Returns the maximum number of spectators allowed in this Room (Game Rooms only). |
int |
getMaxUsers()
Returns the maximum number of users allowed in this Room. |
java.lang.String |
getName()
Indicates the name of this Room. |
java.util.List<User> |
getPlayerList()
Returns a list of User objects representing the players currently inside this Room (Game Rooms only). |
java.util.Map<?,?> |
getProperties()
*Private* |
IRoomManager |
getRoomManager()
A reference to the RoomManager, managing this Room |
int |
getSpectatorCount()
Returns the current number of spectators in this Room (Game Rooms only). |
java.util.List<User> |
getSpectatorList()
Returns a list of User objects representing the spectators currently inside this Room (Game Rooms only). |
User |
getUserById(int id)
Retrieves a User object from its id property. |
User |
getUserByName(java.lang.String name)
*Private* |
int |
getUserCount()
Returns the current number of users in this Room. |
java.util.List<User> |
getUserList()
Returns a list of User objects representing all the users currently inside this Room. |
RoomVariable |
getVariable(java.lang.String name)
*Private* |
java.util.List<RoomVariable> |
getVariables()
*Private* |
boolean |
isGame()
Indicates whether this is a Game Room or not. |
boolean |
isHidden()
Indicates whether this Room is hidden or not. |
boolean |
isJoined()
Indicates whether the client joined this Room or not. |
boolean |
isManaged()
*Private* |
boolean |
isPasswordProtected()
Indicates whether this Room requires a password to be joined or not. |
void |
merge(Room anotherRoom)
*Private* |
void |
removeUser(User user)
*Private* |
void |
setGame(boolean game)
*Private* |
void |
setHidden(boolean hidden)
*Private* |
void |
setJoined(boolean joined)
*Private* |
void |
setManaged(boolean managed)
*Private* |
void |
setMaxSpectators(int maxSpectators)
*Private* |
void |
setMaxUsers(int maxUsers)
*Private* |
void |
setName(java.lang.String name)
*Private* |
void |
setPasswordProtected(boolean passwordProtected)
*Private* |
void |
setProperties(java.util.Map<?,?> properties)
*Private* |
void |
setRoomManager(IRoomManager manager)
*Private* |
void |
setSpectatorCount(int spectatorCount)
*Private* |
void |
setUserCount(int userCount)
*Private* |
void |
setVariable(RoomVariable roomVariable)
*Private* |
void |
setVariables(java.util.List<? extends RoomVariable> roomVariables)
*Private* |
java.lang.String |
toString()
Returns a string that contains the Room id, name and id of the Group to which it belongs. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SFSRoom(int id,
java.lang.String name)
public SFSRoom(int id,
java.lang.String name,
java.lang.String groupId)
NOTE: developers never istantiate a SFSRoom manually: this is done by the SmartFoxServer 2X API internally.
id - The Room id.name - The Room name.groupId - The id of the Group to which the Room belongs.| Method Detail |
|---|
public static Room fromSFSArray(com.smartfoxserver.v2.entities.data.ISFSArray sfsa)
public int getId()
Room
getId in interface Roompublic java.lang.String getName()
RoomNOTE: setting the name property manually has no effect on the server and can disrupt the API functioning. Use the ChangeRoomNameRequest request instead.
getName in interface RoomChangeRoomNameRequestpublic void setName(java.lang.String name)
setName in interface Roompublic java.lang.String getGroupId()
RoomRoom 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.
Default: default
getGroupId in interface RoomSubscribeRoomGroupRequest,
UnsubscribeRoomGroupRequestpublic boolean isJoined()
RoomNOTE: 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.
isJoined in interface RoomJoinRoomRequestpublic boolean isGame()
RoomNOTE: 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.
isGame in interface Roompublic boolean isHidden()
RoomNOTE: 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.
isHidden in interface Roompublic boolean isPasswordProtected()
RoomNOTE: 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.
isPasswordProtected in interface RoomChangeRoomPasswordStateRequestpublic void setPasswordProtected(boolean passwordProtected)
setPasswordProtected in interface Roompublic boolean isManaged()
isManaged in interface Roompublic int getUserCount()
RoomNOTE: setting the userCount property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.
getUserCount in interface Roompublic int getMaxUsers()
RoomNOTE: 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.
getMaxUsers in interface Roompublic int getSpectatorCount()
RoomNOTE: setting the spectatorCount property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.
getSpectatorCount in interface Roompublic int getMaxSpectators()
RoomNOTE: 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.
getMaxSpectators in interface Roompublic int getCapacity()
Room
getCapacity in interface Roompublic void setJoined(boolean joined)
Room
setJoined in interface Roompublic void setGame(boolean game)
Room
setGame in interface Roompublic void setHidden(boolean hidden)
setHidden in interface Roompublic void setManaged(boolean managed)
setManaged in interface Roompublic void setUserCount(int userCount)
Room
setUserCount in interface Roompublic void setMaxUsers(int maxUsers)
Room
setMaxUsers in interface Roompublic void setSpectatorCount(int spectatorCount)
Room
setSpectatorCount in interface Roompublic void setMaxSpectators(int maxSpectators)
Room
setMaxSpectators in interface Roompublic void addUser(User user)
addUser in interface Roompublic void removeUser(User user)
removeUser in interface Roompublic boolean containsUser(User user)
containsUser in interface Roomuser - The User object representing the user whose presence in this Room must be checked.
true if the user is inside this Room; false otherwise.public User getUserByName(java.lang.String name)
getUserByName in interface Roomname - The name of the user to be found.
null if no user with the passed name exists in this Room.Room.getUserById(int)public User getUserById(int id)
Room
getUserById in interface Roomid - The id of the user to be found.
null if no user with the passed id exists in this Room.Room.getUserByName(String)public java.util.List<User> getUserList()
Room
getUserList in interface Roompublic java.util.List<User> getPlayerList()
Room
getPlayerList in interface Roompublic java.util.List<User> getSpectatorList()
Room
getSpectatorList in interface Roompublic RoomVariable getVariable(java.lang.String name)
getVariable in interface Roomname - The name of the Room Variable to be retrieved.
null if no Room Variable with the passed name exists in this Room.Room.getVariables(),
SetRoomVariablesRequestpublic java.util.List<RoomVariable> getVariables()
getVariables in interface RoomRoomVariable,
Room.getVariable(String)public void setVariable(RoomVariable roomVariable)
setVariable in interface Roompublic void setVariables(java.util.List<? extends RoomVariable> roomVariables)
setVariables in interface Roompublic boolean containsVariable(java.lang.String name)
Room
containsVariable in interface Roomname - The name of the Room Variable whose existance in this Room must be checked.
true if a Room Variable with the passed name exists in this Room.public java.util.Map<?,?> getProperties()
getProperties in interface Roompublic void setProperties(java.util.Map<?,?> properties)
setProperties in interface Roompublic IRoomManager getRoomManager()
Room
getRoomManager in interface Room
public void setRoomManager(IRoomManager manager)
throws com.smartfoxserver.v2.exceptions.SFSException
setRoomManager in interface Roomcom.smartfoxserver.v2.exceptions.SFSExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic void merge(Room anotherRoom)
Room
merge in interface Room
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||