//
// INFSmartFoxiPhoneClient.h
// OkeyiPhoneClient
//
// Created by Cem Uzunlar | cem.uzunlar@infosfer.com.
// Copyright 2009 Infosfer Game and Visualization Technologies Ltd. | http://www.infosfer.com All rights reserved.
//
#import <Foundation/Foundation.h>
#import <sys/socket.h>
#import <netinet/in.h>
#import <CFNetwork/CFNetwork.h>
#import <mach/mach_time.h>
#import "NSStreamAddition.h"
#import "NSObjectAddition.h"
#import "INFSendBuffer.h"
#import "INFSmartFoxISFSEvents.h"
#import "SFSHttpConnection.h"
@class INFSmartFoxSysHandler, INFSmartFoxExtHandler, INFSmartFoxRoom, INFSmartFoxBuddy, INFSmartFoxRoomCreateParams;
/*! \mainpage Infosfer SmartFox iPhone Client Documentation
*
* SmartFox iPhone Client is developed by <b>Infosfer Game and Visualization Technologies Ltd.</b>
* http://www.infosfer.com
*
* <b>Author:</b> Cem Uzunlar cem.uzunlar@infosfer.com
*/
/**
* SmartFoxClient is the main class in the SmartFoxServer API.
* This class is responsible for connecting to the server and handling all related events.
*
* <b>NOTE</b>: in the provided examples, <b>smartFox</b> always indicates a SmartFoxClient instance.
*
* \author Infosfer Game and Visualization Technologies Ltd. http://www.infosfer.com
* \author Cem Uzunlar cem.uzunlar@infosfer.com
*
* @version 1.5.4
*
*/
@interface INFSmartFoxiPhoneClient : NSObject<SFSHttpConnectionDelegate> {
@private
NSInteger INFSMARTFOXCLIENT_EOM;
NSString *INFSMARTFOXCLIENT_MSG_XML;
NSString *INFSMARTFOXCLIENT_MSG_JSON;
NSString *INFSMARTFOXCLIENT_MODMSG_TO_USER;
NSString *INFSMARTFOXCLIENT_MODMSG_TO_ROOM;
NSString *INFSMARTFOXCLIENT_MODMSG_TO_ZONE;
NSString *INFSMARTFOXCLIENT_XTMSG_TYPE_XML;
NSString *INFSMARTFOXCLIENT_XTMSG_TYPE_STR;
NSString *INFSMARTFOXCLIENT_XTMSG_TYPE_JSON;
NSString *INFSMARTFOXCLIENT_CONNECTION_MODE_DISCONNECTED;
NSString *INFSMARTFOXCLIENT_CONNECTION_MODE_SOCKET;
NSString *INFSMARTFOXCLIENT_CONNECTION_MODE_HTTP;
@private
NSInputStream *_inStream;
NSOutputStream *_outStream;
NSLock *_receiveLock;
NSMutableData *_receiveBuffer;
NSLock *_sendLock;
NSMutableArray *_sendBuffers;
INFSendBuffer *_lastSendBuffer;
BOOL _noDataSent;
id <INFSmartFoxISFSEvents>_delegate;
@private
NSString *_MSG_STR;
NSInteger _MIN_POLL_SPEED;
NSInteger _DEFAULT_POLL_SPEED;
NSInteger _MAX_POLL_SPEED;
NSString *_HTTP_POLL_REQUEST;
// -------------------------------------------------------
// Properties
// -------------------------------------------------------
@private
NSMutableDictionary *_roomList;
BOOL _connected;
uint64_t _benchStartTime;
mach_timebase_info_data_t _mach_timebase_info_data;
NSInteger _majVersion;
NSInteger _minVersion;
NSInteger _subVersion;
NSMutableDictionary *_messageHandlers;
BOOL _autoConnectOnConfigSuccess;
@public
/**
* The SmartFoxServer IP address.
*
* @see connect:port:
*
* \author Infosfer Game and Visualization Technologies Ltd. http://www.infosfer.com
* \author Cem Uzunlar cem.uzunlar@infosfer.com
*
* @version SmartFoxServer Pro
*/
NSString *_ipAddress;
/**
* The SmartFoxServer connection port.
* The default port is <b>9339</b>.
*
* @see connect:port:
*
* @version SmartFoxServer Pro
*/
NSInteger _port;
/**
* The default login zone.
*
* @see loadConfig:autoConnect:
*
* \author Infosfer Game and Visualization Technologies Ltd. http://www.infosfer.com
* \author Cem Uzunlar cem.uzunlar@infosfer.com
*
* @version SmartFoxServer Pro
*/
NSString *_defaultZone;
//--- BlueBox settings (start) ---------------------------------------------------------------------
@private
BOOL _isHttpMode; // connection mode
NSInteger _httpPollSpeed; // bbox poll speed
SFSHttpConnection* httpConnection;
@public
/**
* The BlueBox IP address.
*
* @see _smartConnect
* @see loadConfig:autoConnect:
*
* \author Infosfer Game and Visualization Technologies Ltd. http://www.infosfer.com
* \author Cem Uzunlar cem.uzunlar@infosfer.com
*
* @since SmartFoxServer Pro v1.6.0
*
* @version SmartFoxServer Pro
*/
NSString *_blueBoxIpAddress;
/**
* The BlueBox connection port.
*
* @see _smartConnect
* @see loadConfig:autoConnect:
*
* \author Infosfer Game and Visualization Technologies Ltd. http://www.infosfer.com
* \author Cem Uzunlar cem.uzunlar@infosfer.com
*
* @since SmartFoxServer Pro v1.6.0
*
* @version SmartFoxServer Pro
*/
NSInteger _blueBoxPort;
/**
* A boolean flag indicating if the BlueBox http connection should be used in case a socket connection is not available.
* The default value is <b>true</b>.
*
* @see loadConfig:autoConnect:
*
* \author Infosfer Game and Visualization Technologies Ltd. http://www.infosfer.com
* \author Cem Uzunlar cem.uzunlar@infosfer.com
*
* @since SmartFoxServer Pro v1.6.0
*
* @version SmartFoxServer Pro
*/
BOOL _smartConnect;
//--- BlueBox settings (end) ---------------------------------------------------------------------
/**
* An array containing the objects representing each buddy of the user's buddy list.
* The buddy list can be iterated with a <i>for-in</i> loop, or a specific object can be retrieved by means of the \link INFSmartFoxiPhoneClient#getBuddyById: getBuddyById \endlink and @link INFSmartFoxiPhoneClient#getBuddyByName: getBuddyByName @endlink methods.
*
* <b>NOTE</b>: this property and all the buddy-related method are available only if the buddy list feature is enabled for the current zone. Check the SmartFoxServer server-side configuration.
*
* Each element in the buddy list is an object with the following properties:
* @param id : (<b>int</b>) the buddy id.
* @param name : (<b>String</b>) the buddy name.
* @param isOnline : (<b>Boolean</b>) the buddy online status: <b>true</b> if the buddy is online; <b>false</b> if the buddy is offline.
* @param isBlocked : (<b>Boolean</b>) the buddy block status: <b>true</b> if the buddy is blocked; <b>false</b> if the buddy is not blocked; when a buddy is blocked, SmartFoxServer does not deliver private messages from/to that user.
* @param variables : (<b>Object</b>) an object with extra properties of the buddy (Buddy Variables); see also @link INFSmartFoxiPhoneClient#setBuddyVariables: setBuddyVariables @endlink.
*
* @see _myBuddyVars
* @see loadBuddyList
* @see getBuddyById:
* @see getBuddyByName:
* @see removeBuddy:
* @see setBuddyBlockStatus:status:
* @see setBuddyVariables:
* @see @link INFSmartFoxISFSEvents-p#onBuddyList: onBuddyList (INFSmartFoxISFSEvents) @endlink
* @see @link INFSmartFoxISFSEvents-p#onBuddyListUpdate: onBuddyListUpdate (INFSmartFoxISFSEvents) @endlink
*
* \author Infosfer Game and Visualization Technologies Ltd. http://www.infosfer.com
* \author Cem Uzunlar cem.uzunlar@infosfer.com
*
* @history SmartFoxServer Pro v1.6.0 - Buddy's <i>isBlocked</i> property added.
*
* @version SmartFoxServer Basic (except block status) / Pro
*/
NSMutableDictionary *_buddyList;
/**
* The current user's Buddy Variables.
* This is an associative array containing the current user's properties when he/she is present in the buddy lists of other users.
* See the @link INFSmartFoxiPhoneClient#setBuddyVariables: setBuddyVariables @endlink method for more details.
*
* @see setBuddyVariables:
* @see getBuddyById:
* @see getBuddyByName:
* @see @link INFSmartFoxISFSEvents-p#onBuddyList: onBuddyList (INFSmartFoxISFSEvents) @endlink
* @see @link INFSmartFoxISFSEvents-p#onBuddyListUpdate: onBuddyListUpdate (INFSmartFoxISFSEvents) @endlink
*
* \author Infosfer Game and Visualization Technologies Ltd. http://www.infosfer.com
* \author Cem Uzunlar cem.uzunlar@infosfer.com
*
* @since SmartFoxServer Pro v1.6.0
*
* @version SmartFoxServer Pro
*/
NSMutableDictionary *_myBuddyVars;
/**
* Toggle the client-side debugging informations.
* When tur