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

#import <SFSUserVariable.h>

Inherits BaseVariable, and <UserVariable>.

Instance Methods

(BOOL) - isPrivate
 
(void) - setPrivate:
 
(id< ISFSArray >) - toSFSArray
 
- Instance Methods inherited from BaseVariable
(id) - initWithName:value:type:
 
(id) - getValue
 
(BOOL) - getBoolValue
 
(NSInteger) - getIntValue
 
(NSNumber *) - getDoubleValue
 
(NSString *) - getStringValue
 
(id< ISFSObject >) - getSFSObjectValue
 
(id< ISFSArray >) - getSFSArrayValue
 
(BOOL) - isNull
 

Class Methods

(id) + variableWithName:value:type:
 
(id) + variableWithName:value:
 
(id< UserVariable >) + fromSFSArray:
 
(id< UserVariable >) + privateVariableWithName:value:
 

Additional Inherited Members

- Protected Attributes inherited from BaseVariable
NSString * _name
 
NSString * _type
 
id _value
 
- Properties inherited from BaseVariable
NSString * name
 
NSString * type
 

Detailed Description

The SFSUserVariable object represents a SmartFoxServer User Variable entity on the client. It is a custom value attached to a User object that gets automatically synchronized between client and server on every change.

User Variables are particularly useful to store custom user data that must be "visible" to the other users, such as a profile, a score, a status message, etc. User Variables can be set by means of the SetUserVariablesRequest request; they support the following data types (also nested): Boolean, int, Number, String, SFSObject, SFSArray. A User Variable can also be null.

Private UserVariables are available since SFS2X 2.12 with client API 1.7 and they allow to limit the visibility of variables marked as private to the owner only. In other words UserVariables marked as private are not sent to other users in the same Room.

See also
User
SetUserVariablesRequest

Method Documentation

◆ isPrivate

- (BOOL) isPrivate

Indicates whether this User Variable is private or not. A private User Variable is visible only to its owner; any changes made to the variable will be transmitted to the owner only.

NOTE: setting the private property manually on an existing User Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the User Variable object is created by the developer only (using the new keyword).

◆ privateVariableWithName:value:

+ (id< UserVariable >) privateVariableWithName: (NSString *)  name
value: (id)  value 

Creates a new private User Variable. Private User Variables are not broadcast to other users: they are only visible on the server side and in the owner's client application.

Parameters
nameThe name of the User Variable
valueThe value of the User Variable
See also
VariableType

◆ variableWithName:value:

+ (id) variableWithName: (NSString *)  name
value: (id)  value 
Parameters
namethe name of the variable
valuethe variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )

Reimplemented from BaseVariable.

◆ variableWithName:value:type:

+ (id) variableWithName: (NSString *)  name
value: (id)  value
type: (NSInteger)  type 
Initial value:
{
@protected
BOOL _isPrivate
Parameters
namethe name of the variable
valuethe variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )
type(optional -1) it's usually not necessary to pass this parameter as the variable value is auto-detected

Reimplemented from BaseVariable.