Inherits from NSObject
Conforms to User
Declared in SFSUser.h
SFSUser.m

Overview

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 to keep track of and interact with his/her friends.

Tasks

  •   id

    Get the unique User Id

    property
  •   playerId

    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.

    property
  •   privilegeId

    Get the privilegeId of the User

    property
  •   name

    The user name

    property
  •   isItMe

    Return true if the User object is the client’s User object, also known as SmartFox2XClient#mySelf

    property
  •   properties

    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.

    property
  •   isPlayer

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

    property
  •   isSpectator

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

    property
  •   userManager

    Get the UserManager of this User

    property
  • – getPlayerId:

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

  • – isGuest

    Return true if the User is logged in as guest user

  • – isStandardUser

    Return true if the User is logged in as standard user

  • – isModerator

    Return true if the User is logged in as moderator user

  • – isAdmin

    Return true if the User is logged in as administrator user

  • – isPlayerInRoom:

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

  • – isSpectatorInRoom:

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

  • – isJoinedInRoom:

    Return true if the User is joined in the specified Room

  • – getVariables

    Get all the User Variables

  • – getVariable:

    Get a UserVariable

  • – containsVariable:

    Check if a UserVariable exists

Properties

id

Get the unique User Id

@property (nonatomic, assign) NSInteger id

Discussion

Get the unique User Id

Declared In

SFSUser.h

isItMe

Return true if the User object is the client’s User object, also known as SmartFox2XClient#mySelf

@property (nonatomic, readonly) BOOL isItMe

Discussion

Return true if the User object is the client’s User object, also known as SmartFox2XClient#mySelf

Declared In

SFSUser.h

isPlayer

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

@property (nonatomic, readonly) BOOL isPlayer

Discussion

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

Declared In

SFSUser.h

isSpectator

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

@property (nonatomic, readonly) BOOL isSpectator

Discussion

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

Declared In

SFSUser.h

name

The user name

@property (nonatomic, readonly) NSString *name

Discussion

The user name

Declared In

SFSUser.h

playerId

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.

@property (nonatomic, readonly) NSInteger playerId

Discussion

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.

Declared In

SFSUser.h

privilegeId

Get the privilegeId of the User

@property (nonatomic, assign) NSInteger privilegeId

Discussion

Get the privilegeId of the User

See Also

Declared In

SFSUser.h

properties

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.

@property (nonatomic, retain) NSMutableDictionary *properties

Discussion

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.

Declared In

SFSUser.h

userManager

Get the UserManager of this User

@property (nonatomic, assign) id<IUserManager> userManager

Discussion

Get the UserManager of this User

See Also

Declared In

SFSUser.h

Instance Methods

containsVariable:

Check if a UserVariable exists

- (BOOL)containsVariable:(NSString *)name

Parameters

name

the name of the variable

Return Value

true if the UserVariable exists

Discussion

Check if a UserVariable exists

See Also

Declared In

SFSUser.h

getPlayerId:

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

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

Discussion

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

Declared In

SFSUser.h

getVariable:

Get a UserVariable

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

Parameters

varName

the name of the variable

Return Value

the UserVariable or nil if the variable doesn’t exist

Discussion

Get a UserVariable

See Also

Declared In

SFSUser.h

getVariables

Get all the User Variables

- (NSArray *)getVariables

Discussion

Get all the User Variables

See Also

Declared In

SFSUser.h

isAdmin

Return true if the User is logged in as administrator user

- (BOOL)isAdmin

Discussion

Return true if the User is logged in as administrator user

Declared In

SFSUser.h

isGuest

Return true if the User is logged in as guest user

- (BOOL)isGuest

Discussion

Return true if the User is logged in as guest user

Declared In

SFSUser.h

isJoinedInRoom:

Return true if the User is joined in the specified Room

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

Discussion

Return true if the User is joined in the specified Room

Declared In

SFSUser.h

isModerator

Return true if the User is logged in as moderator user

- (BOOL)isModerator

Discussion

Return true if the User is logged in as moderator user

Declared In

SFSUser.h

isPlayerInRoom:

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

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

Discussion

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

Declared In

SFSUser.h

isSpectatorInRoom:

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

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

Discussion

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

Declared In

SFSUser.h

isStandardUser

Return true if the User is logged in as standard user

- (BOOL)isStandardUser

Discussion

Return true if the User is logged in as standard user

Declared In

SFSUser.h