iFun Engine API  1.0.0-b2936
Great Technology for Great Games
 All Classes Files Functions Variables Typedefs Macros
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
fun::AccountManager Class Reference
Inheritance diagram for fun::AccountManager:

Public Types

typedef function< void(const
string &, bool)> 
Callback
 
typedef function< void(const
string &, const Rpc::PeerId &)> 
LocateCallback
 
typedef function< void(const
string &, const Ptr< Session >
&, bool)> 
LoginCallback
 
typedef function< void(const
string &, const Ptr< Session >
&, bool)> 
LogoutCallback
 
typedef function< void(const
string &, const Ptr< Session >
&, bool, const string &)> 
RedirectionCallback
 
typedef function< void(const
string &, const Ptr< Session > &)> 
RemoteLogoutCallback
 

Static Public Member Functions

static void BroadcastGlobally (const string &msg_type, const Ptr< FunMessage > &msg, const Rpc::Tag &server_tag, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in sessions of the given RPC servers. More...
 
static void BroadcastGlobally (int32_t msg_type, const Ptr< FunMessage > &msg, const Rpc::Tag &server_tag, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in sessions of the given RPC servers. More...
 
static void BroadcastGlobally (const ProtobufExtensionIdentifier &msg_type, const Ptr< FunMessage > &msg, const Rpc::Tag &server_tag, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in sessions of the given RPC servers. More...
 
static void BroadcastGlobally (const string &msg_type, const Json &msg, const Rpc::Tag &server_tag, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a Json message to all the logged-in sessions of the given RPC servers. More...
 
static void BroadcastGlobally (const string &msg_type, const Ptr< FunMessage > &msg, const Rpc::PeerMap &servers, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in sessions of the given RPC servers. More...
 
static void BroadcastGlobally (int32_t msg_type, const Ptr< FunMessage > &msg, const Rpc::PeerMap &servers, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in sessions of the given RPC servers. More...
 
static void BroadcastGlobally (const ProtobufExtensionIdentifier &msg_type, const Ptr< FunMessage > &msg, const Rpc::PeerMap &servers, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in sessions of the given RPC servers. More...
 
static void BroadcastGlobally (const string &msg_type, const Json &msg, const Rpc::PeerMap &servers, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a Json message to all the logged-in sessions of the given RPC servers. More...
 
static void BroadcastLocally (const string &msg_type, const Ptr< FunMessage > &msg, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in local sessions. More...
 
static void BroadcastLocally (int32_t msg_type, const Ptr< FunMessage > &msg, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in local sessions. More...
 
static void BroadcastLocally (const ProtobufExtensionIdentifier &msg_type, const Ptr< FunMessage > &msg, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a protobuf message to all the logged-in local sessions. More...
 
static void BroadcastLocally (const string &msg_type, const Json &msg, const Encryption &enc, const TransportProtocol &protocol) ASSERT_NO_ROLLBACK
 Broadcasts a Json message to all the the logged-in local sessions. More...
 
static bool CheckAndSetLoggedIn (const string &account_id, const Ptr< Session > &session) ASSERT_NO_ROLLBACK
 Marks the given account logged in this server node. More...
 
static void CheckAndSetLoggedInAsync (const string &account_id, const Ptr< Session > &session, const LoginCallback &callback) ASSERT_NO_ROLLBACK
 Marks the given account logged in this server node. More...
 
static string FindLocalAccount (const Ptr< Session > &session)
 Returns an account string associated with the local session. More...
 
static Ptr< SessionFindLocalSession (const string &account_id)
 Returns a session pointer if the account is attached to a local session. More...
 
static void GetAllLocalAccounts (std::vector< string > *accounts)
 Returns all the accounts attached to the server node. More...
 
static void GetAllLocalAccountsAndSessions (std::vector< std::pair< string, Ptr< Session > > > *accounts)
 Returns all the accounts attached to the server node and sessions. More...
 
static void GetAllLocalSessions (std::vector< Ptr< Session > > *sessions)
 Returns all the sessions of logged-in accounts. More...
 
static size_t GetGlobalAccountsNumber ()
 Returns the total number of logged-in accounts. More...
 
static size_t GetLocalAccountsNumber ()
 Returns the number of accounts attached to the server node. More...
 
static Rpc::PeerId Locate (const string &account_id) ASSERT_NO_ROLLBACK
 Locates a server node hosting the given account. More...
 
static void LocateAsync (const string &account_id, const LocateCallback &callback) ASSERT_NO_ROLLBACK
 Locates a server node hosting the given account. More...
 
static bool RedirectClient (const Ptr< Session > &session, const Rpc::PeerId &peer_id, const string &extra_data) ASSERT_NO_ROLLBACK
 Cooperatively moves client to another server. More...
 
static void RegisterRedirectionHandler (const RedirectionCallback &handler)
 
static void RegisterRemoteLogoutHandler (const RemoteLogoutCallback &handler)
 
static void SendMessage (const string &msg_type, const Ptr< FunMessage > &msg, const string &account_id, const Encryption &enc=kDefaultEncryption, const TransportProtocol &protocol=kDefaultProtocol, const Callback &cb=kNullCallback) ASSERT_NO_ROLLBACK
 Asynchronously sends a protobuf message to the given account. More...
 
static void SendMessage (int32_t msg_type, const Ptr< FunMessage > &msg, const string &account_id, const Encryption &enc=kDefaultEncryption, const TransportProtocol &protocol=kDefaultProtocol, const Callback &cb=kNullCallback) ASSERT_NO_ROLLBACK
 Asynchronously sends a protobuf message to the given account. More...
 
static void SendMessage (const ProtobufExtensionIdentifier &msg_type, const Ptr< FunMessage > &msg, const string &account_id, const Encryption &enc=kDefaultEncryption, const TransportProtocol &protocol=kDefaultProtocol, const Callback &cb=kNullCallback) ASSERT_NO_ROLLBACK
 Asynchronously sends a protobuf message to the given account. More...
 
static void SendMessage (const string &msg_type, const Json &msg, const string &account_id, const Encryption &enc=kDefaultEncryption, const TransportProtocol &protocol=kDefaultProtocol, const Callback &cb=kNullCallback) ASSERT_NO_ROLLBACK
 Asynchronously sends a Json message to the given account. More...
 
static bool SendMessageSync (const string &msg_type, const Ptr< FunMessage > &msg, const string &account_id, const Encryption &enc=kDefaultEncryption, const TransportProtocol &protocol=kDefaultProtocol) ASSERT_NO_ROLLBACK
 Synchronously sends a protobuf message to the given account. More...
 
static bool SendMessageSync (int32_t msg_type, const Ptr< FunMessage > &msg, const string &account_id, const Encryption &enc=kDefaultEncryption, const TransportProtocol &protocol=kDefaultProtocol) ASSERT_NO_ROLLBACK
 Synchronously sends a protobuf message to the given account. More...
 
static bool SendMessageSync (const ProtobufExtensionIdentifier &msg_type, const Ptr< FunMessage > &msg, const string &account_id, const Encryption &enc=kDefaultEncryption, const TransportProtocol &protocol=kDefaultProtocol) ASSERT_NO_ROLLBACK
 Synchronously sends a protobuf message to the given account. More...
 
static bool SendMessageSync (const string &msg_type, const Json &msg, const string &account_id, const Encryption &enc=kDefaultEncryption, const TransportProtocol &protocl=kDefaultProtocol) ASSERT_NO_ROLLBACK
 Synchronously sends a Json message to the given account. More...
 
static bool SetLoggedOut (const string &account_id) ASSERT_NO_ROLLBACK
 Marks the given account logged out of this server node. More...
 
static void SetLoggedOutAsync (const string &account_id, const LogoutCallback &callback) ASSERT_NO_ROLLBACK
 Marks the given account logged out of this server node. More...
 
static bool SetLoggedOutGlobal (const string &account_id) ASSERT_NO_ROLLBACK
 Marks the given account logged out of any server node. More...
 
static void SetLoggedOutGlobalAsync (const string &account_id, const LogoutCallback &callback) ASSERT_NO_ROLLBACK
 Marks the given account logged out of any server node. More...
 

Static Public Attributes

static const Callback kNullCallback
 

Member Function Documentation

static void fun::AccountManager::BroadcastGlobally ( const string &  msg_type,
const Ptr< FunMessage > &  msg,
const Rpc::Tag &  server_tag,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
server_tagRpc::Tag that identify the targets RPC servers.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastGlobally ( int32_t  msg_type,
const Ptr< FunMessage > &  msg,
const Rpc::Tag &  server_tag,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
server_tagRpc::Tag that identify the targets RPC servers.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastGlobally ( const ProtobufExtensionIdentifier msg_type,
const Ptr< FunMessage > &  msg,
const Rpc::Tag &  server_tag,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
server_tagRpc::Tag that identify the targets RPC servers.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastGlobally ( const string &  msg_type,
const Json msg,
const Rpc::Tag &  server_tag,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgreference to a Json instance.
server_tagRpc::Tag that identify the targets RPC servers.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastGlobally ( const string &  msg_type,
const Ptr< FunMessage > &  msg,
const Rpc::PeerMap &  servers,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
serversRpc::PeerMap that identify the targets RPC servers.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastGlobally ( int32_t  msg_type,
const Ptr< FunMessage > &  msg,
const Rpc::PeerMap &  servers,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
serversRpc::PeerMap that identify the targets RPC servers.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastGlobally ( const ProtobufExtensionIdentifier msg_type,
const Ptr< FunMessage > &  msg,
const Rpc::PeerMap &  servers,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
serversRpc::PeerMap that identify the targets RPC servers.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastGlobally ( const string &  msg_type,
const Json msg,
const Rpc::PeerMap &  servers,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgreference to a Json instance.
serversRpc::PeerMap that identify the targets RPC servers.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastLocally ( const string &  msg_type,
const Ptr< FunMessage > &  msg,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastLocally ( int32_t  msg_type,
const Ptr< FunMessage > &  msg,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastLocally ( const ProtobufExtensionIdentifier msg_type,
const Ptr< FunMessage > &  msg,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static void fun::AccountManager::BroadcastLocally ( const string &  msg_type,
const Json msg,
const Encryption &  enc,
const TransportProtocol &  protocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgreference to a Json instance.
encEncryption as with Session::SendMessage()
protocoltransport protocol supports kTcp, kUdp types only.
static bool fun::AccountManager::CheckAndSetLoggedIn ( const string &  account_id,
const Ptr< Session > &  session 
)
static

This information is shared among a cluster of game servers. If the given account has already logged into other server node, reporting will be rejected and this function will return false. (Distribution feature is required enabled.)

Parameters
account_idaccount id in the string form.
sessionpointer to a session instance.
Returns
true if the account was previously not reported logged into other node. false, otherwise.
static void fun::AccountManager::CheckAndSetLoggedInAsync ( const string &  account_id,
const Ptr< Session > &  session,
const LoginCallback &  callback 
)
static

This information is shared among a cluster of game servers. If the given account has already logged into other server node, reporting will be rejected and this function will return false. (Distribution feature is required enabled.)

Parameters
account_idaccount id in the string form.
sessionpointer to a session instance.
callbackfunction to receive a result.
static string fun::AccountManager::FindLocalAccount ( const Ptr< Session > &  session)
static
Returns
account name in string if the session exists and local. empty string, otherwise.
Parameters
sessiona pointer to the session.
static Ptr<Session> fun::AccountManager::FindLocalSession ( const string &  account_id)
static
Returns
pointer to a session instance.
Parameters
account_idaccount id in the string form.
static void fun::AccountManager::GetAllLocalAccounts ( std::vector< string > *  accounts)
static
Parameters
accountscontainer to be filled with the accounts.
static void fun::AccountManager::GetAllLocalAccountsAndSessions ( std::vector< std::pair< string, Ptr< Session > > > *  accounts)
static
Parameters
accountscontainer to be filled with the accounts and sessions
static void fun::AccountManager::GetAllLocalSessions ( std::vector< Ptr< Session > > *  sessions)
static
Parameters
sessionscontainer to be filled with the sessions.
static size_t fun::AccountManager::GetGlobalAccountsNumber ( )
static
Returns
the number of accounts.
static size_t fun::AccountManager::GetLocalAccountsNumber ( )
static
Returns
the number of accounts.
static Rpc::PeerId fun::AccountManager::Locate ( const string &  account_id)
static

The return value can be used to implement user-level RPC messages.

Parameters
account_idaccount id in the string form.
Returns
Rpc::PeerId server node's id.
static void fun::AccountManager::LocateAsync ( const string &  account_id,
const LocateCallback &  callback 
)
static

The return value can be used to implement user-level RPC messages.

Parameters
account_idaccount id in the string form.
callbackfunction to receive server node's id.
static bool fun::AccountManager::RedirectClient ( const Ptr< Session > &  session,
const Rpc::PeerId &  peer_id,
const string &  extra_data 
)
static
Parameters
sessionclient session which will be redirected to another server
peer_idrpc_id for destination server
extra_dataaddtional data to be transferred to destination server
static void fun::AccountManager::SendMessage ( const string &  msg_type,
const Ptr< FunMessage > &  msg,
const string &  account_id,
const Encryption &  enc = kDefaultEncryption,
const TransportProtocol &  protocol = kDefaultProtocol,
const Callback &  cb = kNullCallback 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
account_idaccount id in the string form.
encEncryption as with Session::SendMessage()
protocolProtocol as with Session::SendMessage()
cbCallback instance to be invoked when this RPC request is done.
static void fun::AccountManager::SendMessage ( int32_t  msg_type,
const Ptr< FunMessage > &  msg,
const string &  account_id,
const Encryption &  enc = kDefaultEncryption,
const TransportProtocol &  protocol = kDefaultProtocol,
const Callback &  cb = kNullCallback 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
account_idaccount id in the string form.
encEncryption as with Session::SendMessage()
protocolProtocol as with Session::SendMessage()
cbCallback instance to be invoked when this RPC request is done.
static void fun::AccountManager::SendMessage ( const ProtobufExtensionIdentifier msg_type,
const Ptr< FunMessage > &  msg,
const string &  account_id,
const Encryption &  enc = kDefaultEncryption,
const TransportProtocol &  protocol = kDefaultProtocol,
const Callback &  cb = kNullCallback 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
account_idaccount id in the string form.
encEncryption as with Session::SendMessage()
protocolProtocol as with Session::SendMessage()
cbCallback instance to be invoked when this RPC request is done.
static void fun::AccountManager::SendMessage ( const string &  msg_type,
const Json msg,
const string &  account_id,
const Encryption &  enc = kDefaultEncryption,
const TransportProtocol &  protocol = kDefaultProtocol,
const Callback &  cb = kNullCallback 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgreference to a Json instance.
account_idaccount id in the string form.
encEncryption as with Session::SendMessage()
protocolProtocol as with Session::SendMessage()
cbCallback instance to be invoked when this RPC request is done.
static bool fun::AccountManager::SendMessageSync ( const string &  msg_type,
const Ptr< FunMessage > &  msg,
const string &  account_id,
const Encryption &  enc = kDefaultEncryption,
const TransportProtocol &  protocol = kDefaultProtocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
account_idaccount id in the string form.
encEncryption as with Session::SendMessage()
protocolProtocol as with Session::SendMessage()
Returns
true if successfuly sent the msg to the account. false, otherwise.
static bool fun::AccountManager::SendMessageSync ( int32_t  msg_type,
const Ptr< FunMessage > &  msg,
const string &  account_id,
const Encryption &  enc = kDefaultEncryption,
const TransportProtocol &  protocol = kDefaultProtocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
account_idaccount id in the string form.
encEncryption as with Session::SendMessage()
protocolProtocol as with Session::SendMessage()
Returns
true if successfuly sent the msg to the account. false, otherwise.
static bool fun::AccountManager::SendMessageSync ( const ProtobufExtensionIdentifier msg_type,
const Ptr< FunMessage > &  msg,
const string &  account_id,
const Encryption &  enc = kDefaultEncryption,
const TransportProtocol &  protocol = kDefaultProtocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgpointer to a FunMessage instance.
account_idaccount id in the string form.
encEncryption as with Session::SendMessage()
protocolProtocol as with Session::SendMessage()
Returns
true if successfuly sent the msg to the account. false, otherwise.
static bool fun::AccountManager::SendMessageSync ( const string &  msg_type,
const Json msg,
const string &  account_id,
const Encryption &  enc = kDefaultEncryption,
const TransportProtocol &  protocl = kDefaultProtocol 
)
static
Parameters
msg_typemsg type as with Session::SendMessage()
msgreference to a Json instance.
account_idaccount id in the string form.
encEncryption as with Session::SendMessage()
protocolProtocol as with Session::SendMessage()
Returns
true if successfuly sent the msg to the account. false, otherwise.
static bool fun::AccountManager::SetLoggedOut ( const string &  account_id)
static

After this reporting the account can log in other server.

Parameters
account_idaccount id in the string form.
Returns
true if the account was previously reported logged in. false, oterwise.
static void fun::AccountManager::SetLoggedOutAsync ( const string &  account_id,
const LogoutCallback &  callback 
)
static

After this reporting the account can log in other server.

Parameters
account_idaccount id in the string form.
callbackfunction to receive a result.
static bool fun::AccountManager::SetLoggedOutGlobal ( const string &  account_id)
static

After this reporting the account can log in other server.

Parameters
account_idaccount id in the string form.
Returns
true if the account was previously reported logged in. false, oterwise.
static void fun::AccountManager::SetLoggedOutGlobalAsync ( const string &  account_id,
const LogoutCallback &  callback 
)
static

After this reporting the account can log in other server.

Parameters
account_idaccount id in the string form.
callbackfunction to receive a result.