SFS2X Objective-C API  1.7.13
iOS / macOS / tvOS
SFSUser Class Reference

#import <SFSUser.h>

Inherits NSObject, and <User>.

Instance Methods

(id- initWithId:name:isItMe:
 
(NSInteger) - getPlayerId:
 
(BOOL) - isGuest
 
(BOOL) - isStandardUser
 
(BOOL) - isModerator
 
(BOOL) - isAdmin
 
(BOOL) - isPlayerInRoom:
 
(BOOL) - isSpectatorInRoom:
 
(BOOL) - isJoinedInRoom:
 
(NSArray *) - getVariables
 
(id< UserVariable >) - getVariable:
 
(BOOL) - containsVariable:
 

Class Methods

(id< User >) + fromSFSArray:room:
 

Protected Attributes

NSInteger _id
 
NSInteger _privilegeId
 
NSString * _name
 
BOOL _isItMe
 
NSMutableDictionary * _variables
 
NSMutableDictionary * _properties
 
BOOL _isModerator
 
NSMutableDictionary * _playerIdByRoomId
 
__weak id< IUserManager > _userManager
 

Properties

NSInteger id
 
NSInteger playerId
 
NSInteger privilegeId
 
NSString * name
 
BOOL isItMe
 
NSMutableDictionary * properties
 
BOOL isPlayer
 
BOOL isSpectator
 
id< IUserManager > userManager
 

Detailed Description

The SFSUser object represents a client logged in to the Server.

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. 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.

Method Documentation

◆ containsVariable:

- (BOOL) containsVariable: (NSString *)  name

Check if a UserVariable exists

Parameters
namethe name of the variable
Returns
true if the UserVariable exists
See also
UserVariable

◆ getPlayerId:

- (NSInteger) getPlayerId: (id<Room>)  room

Return the playerId for the specific Room. If you don't use multi-room you can use playerId

◆ getVariable:

- (id< UserVariable >) getVariable: (NSString *)  varName

Get a UserVariable

Parameters
varNamethe name of the variable
Returns
the UserVariable or nil if the variable doesn't exist
See also
UserVariable

◆ getVariables

- (NSArray *) getVariables

Get all the User Variables

See also
UserVariable

◆ isAdmin

- (BOOL) isAdmin

Return true if the User is logged in as administrator user

◆ isGuest

- (BOOL) isGuest

Return true if the User is logged in as guest user

◆ isJoinedInRoom:

- (BOOL) isJoinedInRoom: (id<Room>)  room

Return true if the User is joined in the specified Room

◆ isModerator

- (BOOL) isModerator

Return true if the User is logged in as moderator user

◆ isPlayerInRoom:

- (BOOL) isPlayerInRoom: (id<Room>)  room

Return true if the User is a Player in the specified Room

◆ isSpectatorInRoom:

- (BOOL) isSpectatorInRoom: (id<Room>)  room

Return true if the User is a Spectator in the specified Room

◆ isStandardUser

- (BOOL) isStandardUser

Return true if the User is logged in as standard user

Property Documentation

◆ id

- (NSInteger) id
readwritenonatomicassign

Get the unique User Id

◆ isItMe

- (BOOL) isItMe
readnonatomicassign

Return true if the User object is the client's User object, also known as SmartFox2XClient::mySelf

See also
SmartFox2XClient::mySelf

◆ isPlayer

- (BOOL) isPlayer
readnonatomicassign

Return true if the User is a Player (playerId > 0) in the last joined Room (non game Rooms will always return false)

See also
SmartFox2XClient::lastJoinedRoom

◆ isSpectator

- (BOOL) isSpectator
readnonatomicassign

Return true if the User is a Spectator (playerId < 0) in the last joined Room (non game Rooms will always return false)

See also
SmartFox2XClient::lastJoinedRoom

◆ name

- (NSString *) name
readnonatomicweak

The user name

◆ playerId

- (NSInteger) playerId
readnonatomicassign

Get the playerId of the User. The playerId is different from the User ID and it used to indicate which player number is the user inside a Game Room. Example: in a Game Room for 5 players the first client joining will have playerId = 1, the 2nd will have playerId = 2 and so forth. When a User leaves the Room its player slot is freed up and the next User joining the Room will take it.

The playerId is only applicable for Game Rooms, in the other Rooms it is always == 0 A playerId < 0 indicates that the User is a spectator.

If the User is joined in multiple game Rooms at the same time he will be assigned one playerId per Room.

◆ privilegeId

- (NSInteger) privilegeId
readwritenonatomicassign

Get the privilegeId of the User

See also
UserPrivileges

◆ properties

- (NSMutableDictionary *) properties
readwritenonatomicstrong

A generic object that can be used to store any User custom data needed at runtime. The values added/removed in this object are for client side use only an are never transmitted to the Server.

◆ userManager

- (id< IUserManager >) userManager
readwritenonatomicweak

Get the UserManager of this User

See also
SFSUserManager