SFS2X Objective-C API  1.7.13
iOS / macOS / tvOS
SFSUser.h
1 //
2 // SFSUser.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 "IUserManager.h"
12 #import "Vec3D.h"
13 #import "ISFSArray.h"
14 
15 /** The SFSUser object represents a client logged in to the Server.
16 
17  The client API doesn't know about all Users connected to the server side but only about those that are in the same Rooms where the client is joined.
18  In order to interact with other Users the client can join different Rooms or use a BuddyList to keep track of and interact with his/her friends.
19  */
20 @interface SFSUser : NSObject <User>{
21 @protected
22  NSInteger _id;
23  NSInteger _privilegeId;
24  NSString *_name;
25  BOOL _isItMe;
26  NSMutableDictionary *_variables;
27  NSMutableDictionary *_properties;
28  BOOL _isModerator;
29  NSMutableDictionary *_playerIdByRoomId;
30 
31  __weak id <IUserManager> _userManager;
32 }
33 
34 /** Get the unique User Id */
35 @property (nonatomic, assign) NSInteger id;
36 /**
37  Get the <b>playerId</b> of the User.
38  The <b>playerId</b> is different from the User ID and it used to indicate which player number is the user inside a Game Room.
39  Example: in a Game Room for 5 players the first client joining will have <b>playerId = 1</b>, the 2nd will have <b>playerId = 2</b> and so forth.
40  When a User leaves the Room its player slot is freed up and the next User joining the Room will take it.
41 
42  The <b>playerId</b> is only applicable for Game Rooms, in the other Rooms it is always == 0
43  A playerId &lt; 0 indicates that the User is a spectator.
44 
45  If the User is joined in multiple game Rooms at the same time he will be assigned one <b>playerId</b> per Room.
46  */
47 @property (nonatomic, readonly) NSInteger playerId;
48 /**
49  Get the privilegeId of the User
50  @see UserPrivileges
51  */
52 @property (nonatomic, assign) NSInteger privilegeId;
53 /** The user name */
54 @property (weak, nonatomic, readonly) NSString *name;
55 /**
56  Return true if the User object is the client's User object, also known as SmartFox2XClient#mySelf
57  @see SmartFox2XClient#mySelf
58  */
59 @property (nonatomic, readonly) BOOL isItMe;
60 /**
61  A generic object that can be used to store any User custom data needed at runtime.
62  The values added/removed in this object are for client side use only an are never transmitted to the Server.
63  */
64 @property (nonatomic, strong) NSMutableDictionary *properties;
65 /**
66  Return true if the User is a Player (playerId &gt; 0) in the last joined Room
67  (non game Rooms will always return false)
68 
69  @see SmartFox2XClient#lastJoinedRoom
70  */
71 @property (nonatomic, readonly) BOOL isPlayer;
72 /**
73  Return true if the User is a Spectator (playerId &lt; 0) in the last joined Room
74  (non game Rooms will always return false)
75 
76  @see SmartFox2XClient#lastJoinedRoom
77  */
78 @property (nonatomic, readonly) BOOL isSpectator;
79 /**
80  Get the UserManager of this User
81  @see SFSUserManager
82  */
83 @property (nonatomic, weak) id <IUserManager> userManager;
84 
85 
86 -(id)initWithId:(NSInteger)id name:(NSString *)name isItMe:(BOOL)isItMe;
87 +(id <User>)fromSFSArray:(id <ISFSArray>)sfsa room:(id <Room>)room;
88 
89 /**
90  Return the <b>playerId</b> for the specific Room.
91  If you don't use multi-room you can use playerId
92 
93  */
94 -(NSInteger)getPlayerId:(id<Room>)room;
95 
96 /** Return true if the User is logged in as guest user */
97 -(BOOL)isGuest;
98 /** Return true if the User is logged in as standard user */
99 -(BOOL)isStandardUser;
100 /** Return true if the User is logged in as moderator user */
101 -(BOOL)isModerator;
102 /** Return true if the User is logged in as administrator user */
103 -(BOOL)isAdmin;
104 
105 /** Return true if the User is a Player in the specified Room */
106 -(BOOL)isPlayerInRoom:(id<Room>)room;
107 
108 /** Return true if the User is a Spectator in the specified Room */
109 -(BOOL)isSpectatorInRoom:(id<Room>)room;
110 
111 /** Return true if the User is joined in the specified Room */
112 -(BOOL)isJoinedInRoom:(id<Room>)room;
113 
114 /**
115  Get all the User Variables
116 
117  @see UserVariable
118  */
119 -(NSArray *)getVariables;
120 
121 /**
122 * Get a UserVariable
123 *
124 * @param varName the name of the variable
125 * @return the UserVariable or nil if the variable doesn't exist
126 * @see UserVariable
127 */
128 -(id<UserVariable>)getVariable:(NSString *)varName;
129 
130 /**
131  Check if a UserVariable exists
132 
133  @param name the name of the variable
134  @return true if the UserVariable exists
135  @see UserVariable
136  */
137 -(BOOL)containsVariable:(NSString *)name;
138 @end
SFSUser
Definition: SFSUser.h:20