Package sfs2x.client.entities.managers
Class SFSRoomManager
- java.lang.Object
-
- sfs2x.client.entities.managers.SFSRoomManager
-
- All Implemented Interfaces:
IRoomManager
public class SFSRoomManager extends java.lang.Object implements IRoomManager
The SFSRoomManager class is the entity in charge of managing the client-side Rooms list. It keeps track of all the Rooms available in the client-side Rooms list and of subscriptions to multiple Room Groups. It also provides various utility methods to look for Rooms by name and id, retrieve Rooms belonging to a specific Group, etc.- See Also:
SmartFox.getRoomManager()
-
-
Constructor Summary
Constructors Constructor Description SFSRoomManager(ISmartFox smartFox)
Creates a new SFSRoomManager instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGroup(java.lang.String groupId)
* API internal usage only *void
addRoom(Room room)
* API internal usage only *void
addRoom(Room room, boolean addGroupIfMissing)
* API internal usage only *void
changeRoomCapacity(Room room, int maxUsers, int maxSpect)
* API internal usage only *void
changeRoomName(Room room, java.lang.String newName)
* API internal usage only *void
changeRoomPasswordState(Room room, boolean isPassProtected)
* API internal usage only *boolean
containsGroup(java.lang.String groupId)
Indicates whether the specified Group has been subscribed by the client or not.boolean
containsRoom(int id)
Indicates whether a Room exists in the Rooms list or not.boolean
containsRoom(java.lang.String name)
Indicates whether a Room exists in the Rooms list or not.boolean
containsRoomInGroup(int roomId, java.lang.String groupId)
Indicates whether the Rooms list contains a Room belonging to the specified Group or not.boolean
containsRoomInGroup(java.lang.String roomName, java.lang.String groupId)
Indicates whether the Rooms list contains a Room belonging to the specified Group or not.java.util.List<Room>
getJoinedRooms()
Returns a list of Rooms currently joined by the client.java.lang.String
getOwnerZone()
* API internal usage only *Room
getRoomById(int id)
Retrieves a Room object from its id.Room
getRoomByName(java.lang.String name)
Retrieves a Room object from its name.int
getRoomCount()
Returns the current number of Rooms in the Rooms list.java.util.List<java.lang.String>
getRoomGroups()
Returns the names of Room Groups currently subscribed by the client.java.util.List<Room>
getRoomList()
Returns a list of Rooms currently "known" by the client.java.util.List<Room>
getRoomListFromGroup(java.lang.String groupId)
Retrieves the list of Rooms which are part of the specified Room Group.ISmartFox
getSmartFox()
* API internal usage only *java.util.List<Room>
getUserRooms(User user)
Retrieves a list of Rooms joined by the specified user.void
removeGroup(java.lang.String groupId)
* API internal usage only *void
removeRoom(Room room)
* API internal usage only *void
removeRoomById(int id)
* API internal usage only *void
removeRoomByName(java.lang.String name)
* API internal usage only *void
removeUser(User user)
* API internal usage only *Room
replaceRoom(Room room)
* API internal usage only *Room
replaceRoom(Room room, boolean addToGroupIfMissing)
* API internal usage only *
-
-
-
Constructor Detail
-
SFSRoomManager
public SFSRoomManager(ISmartFox smartFox)
Creates a new SFSRoomManager instance.NOTE: developers never instantiate a SFSRoomManager manually: this is done by the SmartFoxServer 2X API internally. A reference to the existing instance can be retrieved using the SmartFox.getRoomManager() method.
- Parameters:
smartFox
- An instance of the SmartFoxServer 2X client API main SmartFox class.- See Also:
SmartFox.getRoomManager()
-
-
Method Detail
-
getOwnerZone
public java.lang.String getOwnerZone()
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
getOwnerZone
in interfaceIRoomManager
-
addRoom
public void addRoom(Room room)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
addRoom
in interfaceIRoomManager
-
addRoom
public void addRoom(Room room, boolean addGroupIfMissing)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
addRoom
in interfaceIRoomManager
-
addGroup
public void addGroup(java.lang.String groupId)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
addGroup
in interfaceIRoomManager
-
replaceRoom
public Room replaceRoom(Room room)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
replaceRoom
in interfaceIRoomManager
-
replaceRoom
public Room replaceRoom(Room room, boolean addToGroupIfMissing)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
replaceRoom
in interfaceIRoomManager
-
removeGroup
public void removeGroup(java.lang.String groupId)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
removeGroup
in interfaceIRoomManager
-
containsGroup
public boolean containsGroup(java.lang.String groupId)
Description copied from interface:IRoomManager
Indicates whether the specified Group has been subscribed by the client or not.- Specified by:
containsGroup
in interfaceIRoomManager
- Parameters:
groupId
- The name of the Group.- Returns:
true
if the client subscribed the passed Group.
-
containsRoom
public boolean containsRoom(int id)
Description copied from interface:IRoomManager
Indicates whether a Room exists in the Rooms list or not.- Specified by:
containsRoom
in interfaceIRoomManager
- Parameters:
id
- The id of the Room object whose presence in the Rooms list is to be tested.- Returns:
true
if the passed Room exists in the Rooms list.- See Also:
Room.getId()
-
containsRoom
public boolean containsRoom(java.lang.String name)
Description copied from interface:IRoomManager
Indicates whether a Room exists in the Rooms list or not.- Specified by:
containsRoom
in interfaceIRoomManager
- Parameters:
name
- The name of the Room object whose presence in the Rooms list is to be tested.- Returns:
true
if the passed Room exists in the Rooms list.- See Also:
Room.getName()
-
containsRoomInGroup
public boolean containsRoomInGroup(int roomId, java.lang.String groupId)
Description copied from interface:IRoomManager
Indicates whether the Rooms list contains a Room belonging to the specified Group or not.- Specified by:
containsRoomInGroup
in interfaceIRoomManager
- Parameters:
roomId
- The id of the Room object whose presence in the Rooms list is to be tested.groupId
- The name of the Group to which the specified Room must belong.- Returns:
true
if the Rooms list contains the passed Room and it belongs to the specified Group.- See Also:
Room.getId()
,Room.getGroupId()
-
containsRoomInGroup
public boolean containsRoomInGroup(java.lang.String roomName, java.lang.String groupId)
Description copied from interface:IRoomManager
Indicates whether the Rooms list contains a Room belonging to the specified Group or not.- Specified by:
containsRoomInGroup
in interfaceIRoomManager
- Parameters:
roomName
- The name of the Room object whose presence in the Rooms list is to be tested.groupId
- The name of the Group to which the specified Room must belong.- Returns:
true
if the Rooms list contains the passed Room and it belongs to the specified Group.- See Also:
Room.getName()
,Room.getGroupId()
-
changeRoomName
public void changeRoomName(Room room, java.lang.String newName)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
changeRoomName
in interfaceIRoomManager
-
changeRoomPasswordState
public void changeRoomPasswordState(Room room, boolean isPassProtected)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
changeRoomPasswordState
in interfaceIRoomManager
-
changeRoomCapacity
public void changeRoomCapacity(Room room, int maxUsers, int maxSpect)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
changeRoomCapacity
in interfaceIRoomManager
-
getRoomById
public Room getRoomById(int id)
Description copied from interface:IRoomManager
Retrieves a Room object from its id.- Specified by:
getRoomById
in interfaceIRoomManager
- Parameters:
id
- The id of the Room.- Returns:
- An object representing the requested Room;
null
if no Room object with the passed id exists in the Rooms list. Example
The following example retrieves a Room object and traces its name:int roomId = 3; Room room = sfs.getRoomById(roomId); System.out.println("The name of Room " + roomId + " is " + room.getName());
- See Also:
IRoomManager.getRoomByName(String)
-
getRoomByName
public Room getRoomByName(java.lang.String name)
Description copied from interface:IRoomManager
Retrieves a Room object from its name.- Specified by:
getRoomByName
in interfaceIRoomManager
- Parameters:
name
- The name of the Room.- Returns:
- An object representing the requested Room;
null
if no Room object with the passed name exists in the Rooms list. Example
The following example retrieves a Room object and traces its id:String roomName = "The Lobby"; Room room = sfs.getRoomByName(roomName); System.out.println("The ID of Room '" + roomName + "' is " + room.getId());
- See Also:
IRoomManager.getRoomById(int)
-
getRoomList
public java.util.List<Room> getRoomList()
Description copied from interface:IRoomManager
Returns a list of Rooms currently "known" by the client. The list contains all the Rooms that are currently joined and all the Rooms belonging to the Room Groups that have been subscribed.NOTE: at login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
- Specified by:
getRoomList
in interfaceIRoomManager
- Returns:
- The list of the available Room objects.
- See Also:
Room
,JoinRoomRequest
,SubscribeRoomGroupRequest
,UnsubscribeRoomGroupRequest
-
getRoomCount
public int getRoomCount()
Description copied from interface:IRoomManager
Returns the current number of Rooms in the Rooms list.- Specified by:
getRoomCount
in interfaceIRoomManager
- Returns:
- The number of Rooms in the Rooms list.
-
getRoomGroups
public java.util.List<java.lang.String> getRoomGroups()
Description copied from interface:IRoomManager
Returns the names of Room Groups currently subscribed by the client.NOTE: at login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
- Specified by:
getRoomGroups
in interfaceIRoomManager
- Returns:
- A list of Room Group names.
- See Also:
Room.getGroupId()
,SubscribeRoomGroupRequest
,UnsubscribeRoomGroupRequest
-
getRoomListFromGroup
public java.util.List<Room> getRoomListFromGroup(java.lang.String groupId)
Description copied from interface:IRoomManager
Retrieves the list of Rooms which are part of the specified Room Group.- Specified by:
getRoomListFromGroup
in interfaceIRoomManager
- Parameters:
groupId
- The name of the Group.- Returns:
- The list of Room objects belonging to the passed Room Group.
- See Also:
Room
-
getJoinedRooms
public java.util.List<Room> getJoinedRooms()
Description copied from interface:IRoomManager
Returns a list of Rooms currently joined by the client.- Specified by:
getJoinedRooms
in interfaceIRoomManager
- Returns:
- The list of Room objects representing the Rooms currently joined by the client.
- See Also:
Room
,JoinRoomRequest
-
getUserRooms
public java.util.List<Room> getUserRooms(User user)
Description copied from interface:IRoomManager
Retrieves a list of Rooms joined by the specified user. The list contains only those Rooms "known" by the Room Manager; the user might have joined others the client is not aware of.- Specified by:
getUserRooms
in interfaceIRoomManager
- Parameters:
user
- A User object representing the user to look for in the current Rooms list.- Returns:
- The list of Rooms joined by the passed user.
-
removeRoom
public void removeRoom(Room room)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
removeRoom
in interfaceIRoomManager
-
removeRoomById
public void removeRoomById(int id)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
removeRoomById
in interfaceIRoomManager
-
removeRoomByName
public void removeRoomByName(java.lang.String name)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
removeRoomByName
in interfaceIRoomManager
-
removeUser
public void removeUser(User user)
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
removeUser
in interfaceIRoomManager
-
getSmartFox
public ISmartFox getSmartFox()
Description copied from interface:IRoomManager
* API internal usage only *- Specified by:
getSmartFox
in interfaceIRoomManager
-
-