Easemob Windows SDK
emclient.h
1 //
2 // emclient.h
3 // easemob
4 //
5 // Created by zhaoliang on 11/16/15.
6 //
7 //
8 
9 #ifndef __easemob__emclient__
10 #define __easemob__emclient__
11 
12 #include <stdio.h>
13 
14 #include <string>
15 #include "emerror.h"
16 #include "emchatconfigs.h"
17 #include "emcallback.h"
18 #include "emnetworklistener.h"
19 #include "emconnection_listener.h"
20 
21 namespace easemob {
22 
23  // forward declarations
24  class EMChatManagerInterface;
25  class EMGroupManagerInterface;
26  class EMContactManagerInterface;
27  class EMCallManagerInterface;
28  class EMChatClient;
29  class EMChatroomManagerInterface;
30  class EMLoginInfo;
31  class EMTimer;
32 
56  class EASEMOB_API EMClient : public EMNetworkListener, public EMConnectionListener {
57  public:
58  virtual ~EMClient();
59 
67  static EMClient* create(const EMChatConfigsPtr configs);
68 
76  EMErrorPtr login(const std::string &username, const std::string &password);
77 
84  void logout();
85 
92  const EMLoginInfo& getLoginInfo();
93 
100  void addConnectionListener(EMConnectionListener *);
101 
108  void removeConnectionListener(EMConnectionListener *);
109 
117  EMErrorPtr createAccount(const std::string &username, const std::string &password);
118 
126  EMChatConfigsPtr getChatConfigs();
127 
134  EMChatManagerInterface& getChatManager();
135 
142  EMContactManagerInterface& getContactManager();
143 
150  EMGroupManagerInterface& getGroupManager();
151 
158  EMChatroomManagerInterface& getChatroomManager();
159 
167 #if ENABLE_CALL
168  EMCallManagerInterface& getCallManager();
169 #endif
170 
176  virtual void onNetworkChanged(EMNetworkListener::EMNetworkType to);
177 
178  void reconnect();
179  void disconnect();
180 
181  // method from EMConnectionListener
182  void onConnect();
183  void onDisconnect(EMErrorPtr error);
184  void onPong();
185 
186  private:
187  EMClient();
188  void init(const EMChatConfigsPtr configs);
189  EMClient(const EMClient&);
190  EMClient& operator=(const EMClient&);
191  void startHeartBeat();
192  void stopHeartBeat();
193 
194  EMChatClient *mImpl;
195 
196  EMCallbackObserverHandle mHandle;
197  EMTimer *mTimer;
198  };
199 
200 }
201 
202 #endif /* defined(__easemob__emclient__) */
Definition: emlogininfo.h:20
Definition: emclient.h:56
Definition: emnetworklistener.h:19
Definition: emcontactmanager_interface.h:25
Definition: emchatroommanager_interface.h:28
Definition: emchatmanager_interface.h:29
Definition: emconnection_listener.h:17
Definition: emattributevalue.h:28
Definition: emcallback.h:34
Definition: emgroupmanager_interface.h:28