SmartFox2XClient Class Reference
| Inherits from | NSObject |
| Conforms to | IBitSwarmEvents IConfigLoader |
| Declared in | SmartFox2XClient.h SmartFox2XClient.m |
Overview
SmartFox2XClient is the main class in the SFS2X API.
This class is responsible for connecting to the Server and dispatching all asynchronous events.
Warning: Important: in the provided examples, smartFox always indicates a SmartFox2XClient instance.
Tasks
-
buddyManagerReturns the Buddy Manager.
property -
compressionThresholdReturns the current compression threshold.
property -
configGet the current client configuration.
property -
currentIpThe address where the client is connected (if the client is connected)
property -
currentPortThe TCP port of the server where the client is connected (if the client is connected)
property -
currentZoneThe current Zone in use, if user is logged in
property -
debugWhen set to true, provides detailed debugging data for all incoming/outgoing messages
property -
useBlueBoxReturns true if the client connection is http tunnelled
property -
isConnectedReturns true if the client connection is active
property -
joinedRoomsReturns a list of Rooms currently joined by the client
property -
lastJoinedRoomReturn the last joined Room, if any.
property -
loggerGet a reference to the logger
property -
mySelfThis User object represents the User connected to SmartFoxServer 2X
property -
roomListReturns the list of Rooms currently “watched” by the client.
property -
roomManagerReturns the Room Manager.
property -
sessionTokenReturns the unique session token.
property -
userManagerReturns the User Manager.
property -
versionReturn the API current version
property -
– initSmartFoxWithDebugMode:delegate:Initializes SmartFox Client
-
+ smartFoxWithDebugMode:delegate:Initializes and returns SmartFox2XClient instance.
-
– connectEstablish connection with SmartFoxServer 2X.
-
– connect:port:Establish connection with SmartFoxServer 2X.
-
– disconnectDisconnect from SmartFoxServer.
-
– killConnectionSimulate an abrupt disconnection
-
– loadConfig:connectOnSuccess:Load a client configuration file.
-
– send:Sends a request to the Server.
-
– getRoomById:Finds a Room from its Id or returns nil if no Room with that Id exist in the room list
-
– getRoomByName:Finds a Room from its name or returns nil if no Room with that name exist in the room list
-
– getRoomListFromGroup:Return the list of Rooms from a specific Room Group
-
– initUDP:::Initialize the UDP Manager to create a UDP connection. If the host and port parameters are left nil and -1
Properties
buddyManager
Returns the Buddy Manager.
@property (retain) id<IBuddyManager> buddyManagerDiscussion
Returns the Buddy Manager.
See Also
Declared In
SmartFox2XClient.hcompressionThreshold
Returns the current compression threshold.
@property (readonly) NSInteger compressionThresholdDiscussion
Returns the current compression threshold.
The value represent the maximum message size (in bytes) before the protocol compression is activated. The value is determined by the server configuration.
Declared In
SmartFox2XClient.hconfig
Get the current client configuration.
@property (retain) ConfigData *configDiscussion
Get the current client configuration.
It can return null if the configuration was not loaded.
See Also
Declared In
SmartFox2XClient.hcurrentIp
The address where the client is connected (if the client is connected)
@property (readonly) NSString *currentIpDiscussion
The address where the client is connected (if the client is connected)
Declared In
SmartFox2XClient.hcurrentPort
The TCP port of the server where the client is connected (if the client is connected)
@property (readonly) NSInteger currentPortDiscussion
The TCP port of the server where the client is connected (if the client is connected)
Declared In
SmartFox2XClient.hcurrentZone
The current Zone in use, if user is logged in
@property (retain) NSString *currentZoneDiscussion
The current Zone in use, if user is logged in
Declared In
SmartFox2XClient.hdebug
When set to true, provides detailed debugging data for all incoming/outgoing messages
@property (assign) BOOL debugDiscussion
When set to true, provides detailed debugging data for all incoming/outgoing messages
Declared In
SmartFox2XClient.hisConnected
Returns true if the client connection is active
@property (readonly) BOOL isConnectedDiscussion
Returns true if the client connection is active
Declared In
SmartFox2XClient.hjoinedRooms
Returns a list of Rooms currently joined by the client
@property (readonly) NSMutableArray *joinedRoomsDiscussion
Returns a list of Rooms currently joined by the client
See Also
Declared In
SmartFox2XClient.hlastJoinedRoom
Return the last joined Room, if any.
@property (retain) id<Room> lastJoinedRoomDiscussion
Return the last joined Room, if any.
Null is returned if there’s no currently joined Room.
See Also
Declared In
SmartFox2XClient.hlogger
Get a reference to the logger
@property (readonly) Logger *loggerReturn Value
the logger
Discussion
Get a reference to the logger
Declared In
SmartFox2XClient.hmySelf
This User object represents the User connected to SmartFoxServer 2X
@property (retain) id<User> mySelfDiscussion
This User object represents the User connected to SmartFoxServer 2X
See Also
Declared In
SmartFox2XClient.hroomList
Returns the list of Rooms currently “watched” by the client.
@property (readonly) NSArray *roomListDiscussion
Returns the list of Rooms currently “watched” by the client.
The list will contain all the Rooms that are currently joined and all the Rooms from the Room Groups that are subscribed. At login time the User is automatically subscribed to all Room Groups specified in the Zone’s Default Groups setting.
Declared In
SmartFox2XClient.hroomManager
Returns the Room Manager.
@property (retain) id<IRoomManager> roomManagerDiscussion
Returns the Room Manager.
See Also
Declared In
SmartFox2XClient.hsessionToken
Returns the unique session token.
@property (retain) NSString *sessionTokenDiscussion
Returns the unique session token.
The Session token is a String sent by the server to the client after the initial handshake.
Declared In
SmartFox2XClient.huseBlueBox
Returns true if the client connection is http tunnelled
@property (assign) BOOL useBlueBoxDiscussion
Returns true if the client connection is http tunnelled
Declared In
SmartFox2XClient.hClass Methods
smartFoxWithDebugMode:delegate:
Initializes and returns SmartFox2XClient instance.
+ (id)smartFoxWithDebugMode:(BOOL)debug delegate:(id<ISFSEvents>)delegateParameters
- debug
(BOOL) determines debugging mode.
- delegate
(id ISFSEvents) delegate object that listens api events.
Discussion
Initializes and returns SmartFox2XClient instance.
Declared In
SmartFox2XClient.hInstance Methods
connect
Establish connection with SmartFoxServer 2X.
- (void)connectDiscussion
Establish connection with SmartFoxServer 2X.
Client will use the settings loaded via loadConfig
Exceptions
- NSException
if host/address or port in the config file is invalid.
See Also
Declared In
SmartFox2XClient.hconnect:port:
Establish connection with SmartFoxServer 2X.
- (void)connect:(NSString *)host port:(int)portParameters
- host
(NSString *) the address of the server to connect to
- port
(NSInteger) the TCP port (default port used by SFS2X is 9933)
Discussion
Establish connection with SmartFoxServer 2X.
Client will use the settings loaded via loadConfig if you pass nil value for host or -1 for port.
Exceptions
- NSException
if an invalid host/address or port is passed
See Also
Declared In
SmartFox2XClient.hdisconnect
Disconnect from SmartFoxServer.
- (void)disconnectDiscussion
Disconnect from SmartFoxServer.
Declared In
SmartFox2XClient.hgetRoomById:
Finds a Room from its Id or returns nil if no Room with that Id exist in the room list
- (id<Room>)getRoomById:(NSInteger)roomIdParameters
- roomId
(NSInteger) the id of the room.
Discussion
Finds a Room from its Id or returns nil if no Room with that Id exist in the room list
See Also
Declared In
SmartFox2XClient.hgetRoomByName:
Finds a Room from its name or returns nil if no Room with that name exist in the room list
- (id<Room>)getRoomByName:(NSString *)roomNameParameters
- roomName
(NSString *) the name of the room.
Discussion
Finds a Room from its name or returns nil if no Room with that name exist in the room list
See Also
Declared In
SmartFox2XClient.hgetRoomListFromGroup:
Return the list of Rooms from a specific Room Group
- (NSArray *)getRoomListFromGroup:(NSString *)groupIdParameters
- groupId:
(NSString *)the name of the Group
Return Value
the list of rooms
Discussion
Return the list of Rooms from a specific Room Group
See Also
Declared In
SmartFox2XClient.hinitSmartFoxWithDebugMode:delegate:
Initializes SmartFox Client
- (id)initSmartFoxWithDebugMode:(BOOL)debug delegate:(id<ISFSEvents>)delegateParameters
- debug
(BOOL) determines debugging mode.
- delegate
(id ISFSEvents) delegate object that listens api events.
Discussion
Initializes SmartFox Client
See Also
Declared In
SmartFox2XClient.hinitUDP:::
Initialize the UDP Manager to create a UDP connection. If the host and port parameters are left nil and -1
- (void)initUDP:(NSString *)udpHost :Parameters
- udpHost:
(NSString *) the host (IP) of the SFS Server
- udpPort:
(NSInteger) the port of the SFS Server to handle UDP
-(void)onLogin:(SFSEvent *)evt { NSArray *keys = [evt.params allKeys]; for (NSString *key in keys) { // do somthing... } //initialize the UDP socket [smartFox initUDP :nil :-1]; }
Discussion
Initialize the UDP Manager to create a UDP connection. If the host and port parameters are left nil and -1
The UDP Manager will use the settings found in the config XML. UDP is only available through an ExtensionRequest.
Warning: Important: It is recommended to initialize the UDP connection after successful login to a zone.
Declared In
SmartFox2XClient.hkillConnection
Simulate an abrupt disconnection
- (void)killConnectionDiscussion
Simulate an abrupt disconnection
To be used for testing/simulations only.
Declared In
SmartFox2XClient.hloadConfig:connectOnSuccess:
Load a client configuration file.
- (void)loadConfig:(NSString *)filePath connectOnSuccess:(BOOL)connectOnSuccessParameters
- filePath
(NSString *) external xml configuration file name (optional).
- connectOnSuccess
(BOOL) a boolean flag indicating if the connection to SmartFoxServer must be attempted upon configuration loading completion.
Usage Note:
The external xml configuration file has the following structure; ip, port and zone parameters are mandatory, all other parameters are optional.<SmartFoxConfig> <ip>127.0.0.1</ip> <port>9933</port> <udpHost>127.0.0.1</udpHost> <udpPort>9934</udpPort> <zone>BasicExamples</zone> debugtrue</debug> useBlueBoxtrue</useBlueBox> <httpPort>8080</httpPort> <blueBoxPollingRate>750</blueBoxPollingRate> </SmartFoxConfig>Example:
The following example shows how to load an external configuration file.[smartfox loadConfig:@"sfs-config.xml" connectOnSuccess:NO]; -(void)onConfigLoadSuccess:(SFSEvent *)evt { NSLog(@"Config file loaded, now connecting..."); [smartFox connect:smartFox.ipAddress, smartFox.port]; } -(void)onConfigLoadFailure:(SFSEvent *)evt { NSLog(@"Failed loading config file: %@", [evt.params objectForKey:@"message"]); }
Discussion
Load a client configuration file.
The SmartFox2XClient instance can be configured through an external xml configuration file loaded at run-time. By default, the loadConfig method loads a file named sfs—config.xml, placed in the main bundle of the application. If the connectOnSuccess parameter is set to YES, on loading completion the connect:port: method is automatically called by the API, otherwise the onConfigLoadSuccess event is dispatched. In case of a loading error, the onConfigLoadFailure (SmartFoxISFSEvents) event is fired.
Warning: Important: The SmartFox2XClient configuration file (client-side) should not be confused with the SmartFoxServer configuration file (server-side).
Declared In
SmartFox2XClient.hsend:
Sends a request to the Server.
- (void)send:(id<IRequest>)requestParameters
- request
(id IRequest) a request object.
Discussion
Sends a request to the Server.
All the available request objects are found in the documentation.
Declared In
SmartFox2XClient.h