22 #pragma warning(disable:4786) // STL library: disable warning 4786; this warning is generated due to a Microsoft bug 28 #include "Bitswarm/BitSwarmClient.h" 29 #include "Bitswarm/BitSwarmEvent.h" 30 #include "Util/EventDispatcher.h" 31 #include "Core/SFSIOHandler.h" 32 #include "Core/BaseEvent.h" 33 #include "Core/SFSEvent.h" 34 #include "Core/IDispatchable.h" 35 #include "Util/Common.h" 36 #include "Entities/Managers/IUserManager.h" 37 #include "Entities/Room.h" 38 #include "Entities/User.h" 39 #include "Entities/Managers/IBuddyManager.h" 40 #include "Entities/Managers/IRoomManager.h" 41 #include "Exceptions/SFSValidationError.h" 42 #include "FSM/FiniteStateMachine.h" 43 #include "Logging/Logger.h" 44 #include "Requests/IRequest.h" 45 #include "Util/ConfigData.h" 46 #include "Util/ConfigLoader.h" 47 #include "Util/LagMonitor.h" 49 #include <boost/exception/exception.hpp> 50 #include <boost/exception/all.hpp> 51 #include <boost/asio.hpp> 52 #include <boost/shared_ptr.hpp> 53 #include <boost/enable_shared_from_this.hpp> 79 class DLLImportExport
SmartFox :
public IDispatchable,
public boost::enable_shared_from_this<SmartFox>
148 void SetClientDetails(boost::shared_ptr<string> platformId, boost::shared_ptr<string> version);
150 boost::shared_ptr<BitSwarmClient> BitSwarm();
151 boost::shared_ptr<Sfs2X::Logging::Logger> Log();
174 void EnableLagMonitor(
bool enabled,
long int interval,
long int queueSize);
179 void EnableLagMonitor(
bool enabled);
184 void EnableLagMonitor(
bool enabled,
long int interval);
188 boost::shared_ptr<BitSwarmClient> GetSocketEngine();
190 boost::shared_ptr<Sfs2X::Util::LagMonitor> LagMonitor();
207 boost::shared_ptr<string> Version();
218 boost::shared_ptr<string> HttpUploadURI();
225 boost::shared_ptr<ConfigData> Config();
237 void UseBlueBox(
bool value);
248 void ForceIPv6(
bool value);
262 boost::shared_ptr<string> ConnectionMode();
271 long int CompressionThreshold();
280 long int MaxMessageSize();
307 boost::shared_ptr<Room> GetRoomById(
long int id);
338 boost::shared_ptr<Room> GetRoomByName(
string name);
356 boost::shared_ptr<vector<boost::shared_ptr<Room> > > GetRoomListFromGroup(
string groupId);
366 void KillConnection();
399 void Connect(
string host,
long int port);
409 void Connect(
string host);
436 void Connect(boost::shared_ptr<ConfigData> cfg);
454 void ValidateConfig(boost::shared_ptr<ConfigData> cfg);
469 boost::shared_ptr<string> GetIPAddress(
string host,
long int port);
480 void Debug(
bool value);
488 boost::shared_ptr<string> CurrentIp();
496 long int CurrentPort();
504 boost::shared_ptr<string> CurrentZone();
515 boost::shared_ptr<User> MySelf();
516 void MySelf(boost::shared_ptr<User> value);
521 boost::shared_ptr<Sfs2X::Logging::Logger>
Logger();
533 boost::shared_ptr<Room> LastJoinedRoom();
534 void LastJoinedRoom(boost::shared_ptr<Room> value);
547 boost::shared_ptr<vector<boost::shared_ptr<Room> > > JoinedRooms();
562 boost::shared_ptr<vector<boost::shared_ptr<Room> > > RoomList();
572 boost::shared_ptr<IRoomManager> RoomManager();
582 boost::shared_ptr<IUserManager> UserManager();
592 boost::shared_ptr<IBuddyManager> BuddyManager();
622 void InitUDP(
string udpHost);
683 void InitUDP(
string udpHost,
short int udpPort);
686 void IsJoining(
bool value);
694 boost::shared_ptr<string> SessionToken();
699 void DispatchEvent(boost::shared_ptr<BaseEvent> evt);
708 bool ThreadSafeMode();
709 void ThreadSafeMode(
bool value);
712 long int GetReconnectionSeconds();
715 void SetReconnectionSeconds(
long int seconds);
761 void Send(boost::shared_ptr<IRequest> request);
824 void LoadConfig(
string filePath,
bool connectOnSuccess);
829 void LoadConfig(
string filePath);
834 void LoadConfig(
bool connectOnSuccess);
858 void AddLogListener(Sfs2X::Logging::LogLevel logLevel, boost::shared_ptr<EventListenerDelegate> eventListener);
860 void AddJoinedRoom(boost::shared_ptr<Room> room);
861 void RemoveJoinedRoom(boost::shared_ptr<Room> room);
866 void HandleHandShake(boost::shared_ptr<BaseEvent> evt);
868 void HandleLogin(boost::shared_ptr<BaseEvent> evt);
870 void HandleClientDisconnection(boost::shared_ptr<string> reason);
889 void HttpPort(
unsigned short int httpPort);
904 void ProcessEvents();
941 void AddEventListener(boost::shared_ptr<string> eventType, boost::shared_ptr<EventListenerDelegate> listener);
948 void RemoveEventListener (boost::shared_ptr<string> eventType, boost::shared_ptr<EventListenerDelegate> listener);
956 void RemoveAllEventListeners();
958 boost::shared_ptr<boost::asio::io_service> GetBoostService();
961 void HandleReconnectionFailure();
1052 void DisconnectConnection(
long int timeout);
1054 void HandleConnectionProblem(boost::shared_ptr<BaseEvent> e);
1055 void SendHandshakeRequest(
bool isReconnection);
1056 void EnqueueEvent(boost::shared_ptr<BaseEvent> evt);
1057 void OnDisconnectConnectionEvent(
const boost::system::error_code& code);
1058 void CleanEventParams(boost::shared_ptr<BaseEvent> e);
1063 boost::shared_ptr<EventDispatcher> Dispatcher();
1069 static void OnSocketConnect(
unsigned long long context, boost::shared_ptr<BaseEvent> e);
1070 static void OnSocketClose(
unsigned long long context, boost::shared_ptr<BaseEvent> e);
1071 static void OnSocketReconnectionTry(
unsigned long long context, boost::shared_ptr<BaseEvent> e);
1072 static void OnSocketDataError(
unsigned long long context, boost::shared_ptr<BaseEvent> e);
1073 static void OnSocketIOError(
unsigned long long context, boost::shared_ptr<BaseEvent> e);
1074 static void OnSocketSecurityError(
unsigned long long context, boost::shared_ptr<BaseEvent> e);
1075 static void OnConfigLoadSuccess(
unsigned long long context, boost::shared_ptr<BaseEvent> e);
1076 static void OnConfigLoadFailure(
unsigned long long context, boost::shared_ptr<BaseEvent> e);
1082 const static long int DEFAULT_HTTP_PORT = 8080;
1083 const static long int MAX_BB_CONNECT_ATTEMPTS = 3;
1084 const static char CLIENT_TYPE_SEPARATOR =
':';
1087 long int majVersion;
1088 long int minVersion;
1089 long int subVersion;
1091 boost::shared_ptr<BitSwarmClient> bitSwarm;
1094 boost::shared_ptr<string> clientDetails;
1096 boost::shared_ptr<Sfs2X::Util::LagMonitor> lagMonitor;
1108 boost::shared_ptr<User> mySelf;
1111 boost::shared_ptr<string> sessionToken;
1114 boost::shared_ptr<Room> lastJoinedRoom;
1117 boost::shared_ptr<Sfs2X::Logging::Logger> log;
1126 bool threadSafeMode;
1132 boost::shared_ptr<IUserManager> userManager;
1135 boost::shared_ptr<IRoomManager> roomManager;
1138 boost::shared_ptr<IBuddyManager> buddyManager;
1140 boost::shared_ptr<ConfigData> config;
1143 boost::shared_ptr<string> currentZone;
1146 bool autoConnectOnConfig;
1149 boost::shared_ptr<string> lastIpAddress;
1151 boost::shared_ptr<EventDispatcher> dispatcher;
1153 boost::shared_ptr<SynchronizationObject> eventsLocker;
1155 boost::shared_ptr<vector<boost::shared_ptr<BaseEvent> > > eventsQueue;
1157 long int bbConnectionAttempt;
1159 boost::shared_ptr<boost::asio::io_service> service;
1160 boost::shared_ptr<boost::asio::deadline_timer> disconnectTimer;
Definition: SFSCodecError.cpp:14
The internal logger used by the SmartFoxServer 2X client API.
Definition: Logger.h:56
Definition: BaseEvent.cpp:14
Definition: Logger.cpp:14
Definition: IBuddyManager.h:32
Definition: BaseController.cpp:14
Definition: AdminMessageRequest.cpp:14
Definition: BuddyOnlineState.h:15
SmartFox is the main class of the SmartFoxServer 2X API.
Definition: SmartFox.h:79
Definition: SmartFox.cpp:24
Definition: ISFSArray.h:17