9 #ifndef INCLUDE_FUNAPI_SERVICE_ACCOUNT_MANAGER_H_ 10 #define INCLUDE_FUNAPI_SERVICE_ACCOUNT_MANAGER_H_ 12 #include <boost/noncopyable.hpp> 25 typedef function<void(
const string & ,
bool )> Callback;
26 typedef function<void(
const string & ,
28 bool )> LoginCallback;
29 typedef function<void(
const string &,
31 bool )> LogoutCallback;
32 typedef function<void(
const string &,
33 const Ptr<Session> &)> RemoteLogoutCallback;
34 typedef function<void(
const string &,
35 const Rpc::PeerId &)> LocateCallback;
38 typedef function<void (
const string & ,
39 const Ptr<Session> & ,
41 const string & )> RedirectionCallback;
42 typedef function<void (
size_t ,
43 bool )> GlobalAccountsNumberCallback;
45 enum RedirectClientResult {
54 void(
const Ptr<Session> &,
57 RedirectClientResult )> RedirectClientCallback;
59 static const Callback kNullCallback;
61 static void RegisterRemoteLogoutHandler(
const RemoteLogoutCallback &handler);
62 static void RegisterRedirectionHandler(
const RedirectionCallback &handler);
73 static bool CheckAndSetLoggedIn(
74 const string &account_id,
75 const Ptr<Session> &session) ASSERT_NO_ROLLBACK;
85 static void CheckAndSetLoggedInAsync(
86 const string &account_id,
87 const Ptr<Session> &session,
88 const LoginCallback &callback) ASSERT_NO_ROLLBACK;
101 static void CheckAndSetLoggedInAsync(
102 const string &account_id,
103 const Ptr<Session> &session,
104 const size_t &max_retry,
105 const LoginCallback &login_callback,
106 const LogoutCallback &logout_callback) ASSERT_NO_ROLLBACK;
113 static bool SetLoggedOut(
const string &account_id) ASSERT_NO_ROLLBACK;
120 static bool SetLoggedOut(
const Ptr<Session> &session) ASSERT_NO_ROLLBACK;
126 static void SetLoggedOutAsync(
127 const string &account_id,
128 const LogoutCallback &callback) ASSERT_NO_ROLLBACK;
134 static void SetLoggedOutAsync(
135 const Ptr<Session> &session,
136 const LogoutCallback &callback) ASSERT_NO_ROLLBACK;
143 static bool SetLoggedOutGlobal(
const string &account_id) ASSERT_NO_ROLLBACK;
149 static void SetLoggedOutGlobalAsync(
150 const string &account_id,
151 const LogoutCallback &callback) ASSERT_NO_ROLLBACK;
155 static void GetAllLocalAccounts(std::vector<string> *accounts);
159 static void GetAllLocalSessions(std::vector<Ptr<Session> > *sessions);
163 static void GetAllLocalAccountsAndSessions(
164 std::vector<std::pair<
string, Ptr<Session> > > *accounts);
168 static size_t GetLocalAccountsNumber();
172 static int64_t GetGlobalAccountsNumber();
174 static void GetGlobalAccountsNumberAsync(
175 const GlobalAccountsNumberCallback& callback);
181 static bool IsLoggedIn(
const Ptr<Session> &session);
187 static Rpc::PeerId Locate(
const string &account_id) ASSERT_NO_ROLLBACK;
193 static void LocateAsync(
194 const string &account_id,
195 const LocateCallback &callback) ASSERT_NO_ROLLBACK;
200 static Ptr<Session> FindLocalSession(
const string &account_id);
206 static string FindLocalAccount(
const Ptr<Session> &session);
215 static void SendMessage(
216 const string &msg_type,
const Ptr<FunMessage> &msg,
217 const string &account_id,
const Encryption &enc = kDefaultEncryption,
218 const TransportProtocol &protocol = kDefaultProtocol,
219 const Callback &cb = kNullCallback) ASSERT_NO_ROLLBACK;
228 static void SendMessage(
229 int32_t msg_type,
const Ptr<FunMessage> &msg,
230 const string &account_id,
const Encryption &enc = kDefaultEncryption,
231 const TransportProtocol &protocol = kDefaultProtocol,
232 const Callback &cb = kNullCallback) ASSERT_NO_ROLLBACK;
241 static void SendMessage(
243 const string &account_id,
const Encryption &enc = kDefaultEncryption,
244 const TransportProtocol &protocol = kDefaultProtocol,
245 const Callback &cb = kNullCallback) ASSERT_NO_ROLLBACK;
254 static void SendMessage(
255 const string &msg_type,
const Json &msg,
const string &account_id,
256 const Encryption &enc = kDefaultEncryption,
257 const TransportProtocol &protocol = kDefaultProtocol,
258 const Callback &cb = kNullCallback) ASSERT_NO_ROLLBACK;
267 static bool SendMessageSync(
268 const string &msg_type,
const Ptr<FunMessage> &msg,
269 const string &account_id,
const Encryption &enc = kDefaultEncryption,
270 const TransportProtocol &protocol = kDefaultProtocol) ASSERT_NO_ROLLBACK;
279 static bool SendMessageSync(
280 int32_t msg_type,
const Ptr<FunMessage> &msg,
281 const string &account_id,
const Encryption &enc = kDefaultEncryption,
282 const TransportProtocol &protocol = kDefaultProtocol) ASSERT_NO_ROLLBACK;
291 static bool SendMessageSync(
293 const string &account_id,
const Encryption &enc = kDefaultEncryption,
294 const TransportProtocol &protocol = kDefaultProtocol) ASSERT_NO_ROLLBACK;
303 static bool SendMessageSync(
304 const string &msg_type,
const Json &msg,
305 const string &account_id,
const Encryption &enc = kDefaultEncryption,
306 const TransportProtocol &protocl = kDefaultProtocol) ASSERT_NO_ROLLBACK;
313 static void BroadcastLocally(
314 const string &msg_type,
const Ptr<FunMessage> &msg,
315 const Encryption &enc,
316 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
323 static void BroadcastLocally(
324 int32_t msg_type,
const Ptr<FunMessage> &msg,
325 const Encryption &enc,
326 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
333 static void BroadcastLocally(
335 const Encryption &enc,
336 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
343 static void BroadcastLocally(
344 const string &msg_type,
const Json &msg,
345 const Encryption &enc,
346 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
355 static void BroadcastGlobally(
356 const string &msg_type,
const Ptr<FunMessage> &msg,
357 const Rpc::Tag &server_tag,
358 const Encryption &enc,
359 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
368 static void BroadcastGlobally(
369 int32_t msg_type,
const Ptr<FunMessage> &msg,
370 const Rpc::Tag &server_tag,
371 const Encryption &enc,
372 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
381 static void BroadcastGlobally(
383 const Rpc::Tag &server_tag,
384 const Encryption &enc,
385 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
394 static void BroadcastGlobally(
395 const string &msg_type,
const Json &msg,
396 const Rpc::Tag &server_tag,
397 const Encryption &enc,
398 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
407 static void BroadcastGlobally(
408 const string &msg_type,
const Ptr<FunMessage> &msg,
409 const Rpc::PeerMap &servers,
410 const Encryption &enc,
411 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
420 static void BroadcastGlobally(
421 int32_t msg_type,
const Ptr<FunMessage> &msg,
422 const Rpc::PeerMap &servers,
423 const Encryption &enc,
424 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
433 static void BroadcastGlobally(
435 const Rpc::PeerMap &servers,
436 const Encryption &enc,
437 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
446 static void BroadcastGlobally(
447 const string &msg_type,
const Json &msg,
448 const Rpc::PeerMap &servers,
449 const Encryption &enc,
450 const TransportProtocol &protocol) ASSERT_NO_ROLLBACK;
456 static bool RedirectClient(
457 const Ptr<Session> &session,
const Rpc::PeerId &peer_id,
458 const string &extra_data) ASSERT_NO_ROLLBACK;
465 static void RedirectClientAsync(
466 const Ptr<Session> &session,
const Rpc::PeerId &peer_id,
467 const string &extra_data,
468 const RedirectClientCallback &callback) ASSERT_NO_ROLLBACK;
472 FUNAPI_DLL_VISIBILITY
473 std::ostream &operator<<(std::ostream &stream,
474 const AccountManager::RedirectClientResult result);
478 #endif // INCLUDE_FUNAPI_SERVICE_ACCOUNT_MANAGER_H_
Definition: session.h:624
Definition: account_manager.h:23