SFS2X Objective-C API  1.7.13
iOS / macOS / tvOS
SFSRoom.h
1 //
2 // SFSRoom.h
3 // SFS2X
4 //
5 // Original development by Infosfer Game Technologies Ltd. | http://www.infosfer.com.
6 //
7 // Maintained and developed by A51 Integrated.
8 // Copyright 2012 A51 Integrated | http://a51integrated.com. All rights reserved.
9 //
10 
11 #import "Room.h"
12 #import "IUserManager.h"
13 #import "IRoomManager.h"
14 #import "ISFSArray.h"
15 
16 
17 /** The Room object that represents a server Room.
18 
19  The client API doesn't know about all Rooms on the server side but only about those that are joined and those in the Room Groups that were subscribed.
20 
21  Subscribing to one or more Groups allows the client to listen for Room events in specific "areas" of the Zone without having to know and download details for all Rooms available.
22 
23  The RoomList is created after a succesful login in the SmartFox2XClient roomList object and it is kept updated at all times by the Server.
24 
25  @see [SmartFox2XClient roomList]
26  @see CreateRoomRequest
27  @see JoinRoomRequest
28  @see SubscribeRoomGroupRequest
29  @see UnsubscribeRoomGroupRequest
30  @see ChangeRoomNameRequest
31  @see ChangeRoomPasswordStateRequest
32  @see ChangeRoomCapacityRequest
33 
34  */
35 @interface SFSRoom : NSObject <Room>
36 {
37 
38 @protected
39  NSInteger _id;
40  NSString *_name;
41  NSString *_groupId;
42  BOOL _isGame;
43  BOOL _isHidden;
44  BOOL _isJoined;
45  BOOL _isPasswordProtected;
46  BOOL _isManaged;
47  NSMutableDictionary *_variables;
48  NSDictionary *_properties;
49  id <IUserManager> _userManager;
50  NSInteger _maxUsers;
51  NSInteger _maxSpectators;
52  NSInteger _userCount;
53  NSInteger _spectatorCount;
54  __weak id <IRoomManager> _roomManager;
55 }
56 
57 /**
58  The unique id of the Room
59  */
60 @property (nonatomic, readonly) NSInteger id;
61 
62 /**
63  The Room name
64  */
65 @property (nonatomic, strong) NSString *name;
66 
67 /**
68  The Room Group. Each Room is assigned to its Group.
69  By default SmartFoxServer uses one single group called <i>default</i>
70  */
71 @property (weak, nonatomic, readonly) NSString *groupId;
72 
73 /**
74  Determines if a Room is a Game Room
75  */
76 @property (nonatomic, assign) BOOL isGame;
77 
78 
79 /**
80  Determines if the Room is hidden
81  */
82 @property (nonatomic, assign) BOOL isHidden;
83 
84 /**
85  Returns true if the Room is joined by the current User
86  */
87 @property (nonatomic, assign) BOOL isJoined;
88 
89 /**
90  Returns true if the Room requires a password for joining it
91  */
92 @property (nonatomic, assign) BOOL isPasswordProtected;
93 
94 @property (nonatomic, assign) BOOL isManaged;
95 
96 /**
97  Get the maximum number of users allowed for this Room
98  */
99 @property (nonatomic, assign) NSInteger maxUsers;
100 
101 /**
102  Get the maximum number of spectators allowed in the Room
103  */
104 @property (nonatomic, assign) NSInteger maxSpectators;
105 
106 /**
107  Get the current number of users
108  */
109 @property (nonatomic, assign) NSInteger userCount;
110 
111 /**
112 * Returns the max amount of users (both Users and Spectators) that can be contained in this room
113 */
114 @property (nonatomic, readonly) NSInteger capacity;
115 
116 /**
117  Get the number of spectators (only for Game Rooms)
118  */
119 @property (nonatomic, assign) NSInteger spectatorCount;
120 
121 /**
122  The properties object can be used to store any custom value/object to the Room at runtime
123  */
124 @property (nonatomic, strong) NSDictionary *properties;
125 
126 @property (nonatomic, weak) id <IRoomManager> roomManager;
127 
128 /**
129  Get the full list of users in the Room
130  */
131 @property (weak, nonatomic, readonly) NSArray *userList;
132 
133 /**
134  Returns all the Users that are players in this Room (must be Game Room)
135  */
136 @property (weak, nonatomic, readonly) NSArray *playerList;
137 
138 /**
139  Returns all the Users that are spectators in this Room (must be Game Room)
140  */
141 @property (weak, nonatomic, readonly) NSArray *spectatorList;
142 
143 
144 -(id)initWithId:(NSInteger)id name:(NSString *)name groupId:(NSString *)groupId;
145 +(id <Room>)fromSFSArray:(id <ISFSArray>)sfsa;
146 
147 
148 /** Returns all the Room Variables
149 
150  @return an array of Room Variables
151  */
152 -(NSArray *)getVariables;
153 
154 /** Get a Room Variable
155 
156  @param name the name of the variable
157  @return the Room Variable, or null if no variable exists with that name
158  */
159 -(id <RoomVariable>)getVariable:(NSString *)name;
160 
161 
162 /** Get a User from its name
163 
164  @return the User, or null if no User with that name exists in the Room
165  */
166 -(id <User>)getUserByName:(NSString *)name;
167 
168 
169 /** Get a User from its ID
170  @return the User, or null if no User with that ID exists in the Room
171  */
172 -(id <User>)getUserById:(NSInteger)id;
173 
174 /** Check for the presence of a Room Variable
175 
176  @return true if the the Room Variable exists
177  */
178 -(BOOL)containsVariable:(NSString *)name;
179 
180 /** Checks if a User is joined in this Room
181 
182  @return true if the User exists in the Room
183  */
184 -(BOOL)containsUser:(id <User>)user;
185 
186 -(void)merge:(id<Room>)anotherRoom;
187 
188 @end
SFSRoom
Definition: SFSRoom.h:35