Eris
1.4.0
|
Encapsulates all the state of an Atlas Account, and methods that operation on that state. More...
#include <Account.h>
Public Member Functions | |
Account (Connection *con) | |
Create a new Account associated with a Connection object. More... | |
Result | login (const std::string &uname, const std::string &pwd) |
Login to the server using user-supplied account information. More... | |
Result | createAccount (const std::string &uname, const std::string &fullName, const std::string &pwd) |
Attempt to create a new account on the server and log into it. | |
Result | createAccount (const Atlas::Objects::Entity::Account &accountOp) |
Result | logout () |
Request logout from the server. More... | |
bool | isLoggedIn () const |
Check if the account is logged in. More... | |
const std::vector< std::string > & | getCharacterTypes () const |
Returns a container of character types that the client is allowed to create. | |
const CharacterMap & | getCharacters () |
Get the characters owned by this account. More... | |
Result | refreshCharacterInfo () |
Update the character list (based on changes to play). More... | |
Result | takeTransferredCharacter (const std::string &id, const std::string &key) |
Transfer all characters to this account and then do all steps in takeCharacter() More... | |
Result | takeCharacter (const std::string &id) |
Enter the game using an existing character. More... | |
Result | createCharacter (const Atlas::Objects::Entity::RootEntity &character) |
enter the game using a new character | |
bool | canCreateCharacter () |
pop up the game's character creation dialog, if present More... | |
const ActiveCharacterMap & | getActiveCharacters () const |
Gets a list of active characters, i.e. More... | |
const SpawnPointMap & | getSpawnPoints () const |
Gets the available spawn points from where the client can create new characters. More... | |
Result | deactivateCharacter (Avatar *av) |
Request de-activation of a character. More... | |
const std::string & | getId () const |
returns the account ID if logged in | |
const std::string & | getUsername () const |
Return the username of this account. More... | |
const std::string & | getParent () const |
Gets the parent type of the account. | |
Connection * | getConnection () const |
Access the underlying Connection for this account. | |
void | avatarLogoutRequested (Avatar *avatar) |
Called when a logout of the avatar has been requested by the server. More... | |
Public Attributes | |
sigc::signal< void, const Atlas::Objects::Entity::RootEntity & > | GotCharacterInfo |
emitted when a character has been retrieved from the server | |
sigc::signal< void > | GotAllCharacters |
emitted when the entire character list had been updated | |
sigc::signal< void, const std::string & > | LoginFailure |
Emitted when a server-side error occurs during account creation / login. More... | |
sigc::signal< void > | LoginSuccess |
Emitted when login or character creation is successful. More... | |
sigc::signal< void, bool > | LogoutComplete |
Emitted when a logout completes. More... | |
sigc::signal< void, Avatar * > | AvatarSuccess |
Emitted when creating a character or taking an existing one succeeds. | |
sigc::signal< void, const std::string & > | AvatarFailure |
Emitted when creating or taking a character fails for some reason. More... | |
sigc::signal< void, Avatar * > | AvatarDeactivated |
Emitted when an active avatar is deactivated. More... | |
sigc::signal< void, const std::string & > | ErrorMessage |
Emitted when an error message is received. | |
Protected Types | |
enum | Status { DISCONNECTED = 0, LOGGING_IN, LOGGED_IN, LOGGING_OUT, TAKING_CHAR, CREATING_CHAR } |
Protected Member Functions | |
void | sightCharacter (const Atlas::Objects::Operation::RootOperation &op) |
void | loginComplete (const Atlas::Objects::Entity::Account &p) |
void | loginError (const Atlas::Objects::Operation::Error &err) |
Result | internalLogin (const std::string &unm, const std::string &pwd) |
void | internalLogout (bool clean) |
void | netConnected () |
Callback for network re-establishment. | |
bool | netDisconnecting () |
help! the plug is being pulled! | |
void | netFailure (const std::string &msg) |
void | loginResponse (const Atlas::Objects::Operation::RootOperation &op) |
void | logoutResponse (const Atlas::Objects::Operation::RootOperation &op) |
void | possessResponse (const Atlas::Objects::Operation::RootOperation &op) |
void | avatarCreateResponse (const Atlas::Objects::Operation::RootOperation &op) |
void | avatarLogoutResponse (const Atlas::Objects::Operation::RootOperation &op) |
void | destroyAvatar (const std::string &avatarId) |
Destroys the avatar with the specified id, if available. More... | |
void | handleLogoutTimeout () |
void | handleLoginTimeout () |
void | internalDeactivateCharacter (Avatar *av) |
virtual void | updateFromObject (const Atlas::Objects::Entity::Account &p) |
Protected Attributes | |
Connection * | m_con |
underlying connection instance | |
Status | m_status |
what the Player is currently doing | |
AccountRouter * | m_router |
std::string | m_accountId |
the account ID | |
std::string | m_username |
The player's username ( != account object's ID) | |
std::string | m_pass |
std::string | m_parent |
std::vector< std::string > | m_characterTypes |
CharacterMap | _characters |
characters belonging to this player | |
StringSet | m_characterIds |
bool | m_doingCharacterRefresh |
set if we're refreshing character data | |
ActiveCharacterMap | m_activeCharacters |
std::unique_ptr< TimedEvent > | m_timeout |
SpawnPointMap | m_spawnPoints |
A map of available spawn points. More... | |
Friends | |
class | AccountRouter |
class | Avatar |
Encapsulates all the state of an Atlas Account, and methods that operation on that state.
An Account object represents the encapsulation of a server account, and it's binding to a character in the game world. Future versions of Eris will support multiple Account objects per Connection, allowing various configurations of interface, proxies and so forth.
Account is also the mechanism by which Lobby and Avatars objects are made available to the client, in response to login / create operations
|
protected |
|
explicit |
Create a new Account associated with a Connection object.
Create a new Account object : currently only one is assumed, but multiple Accounts might be supported in the future
con | A valid (but not necessarily connected) Connection instance |
References Eris::BaseConnection::Connected, deactivateCharacter(), Eris::Connection::Failure, isLoggedIn(), logout(), m_con, and netConnected().
void Eris::Account::avatarLogoutRequested | ( | Avatar * | avatar | ) |
Called when a logout of the avatar has been requested by the server.
avatar | The avatar which is being logged out. This instance will be destroyed once this method is done. |
References AvatarDeactivated.
|
inline |
pop up the game's character creation dialog, if present
returns true if the game has defined a character creation dialog
Request de-activation of a character.
The 'AvatarDeactivated' signal will be emitted when the deactivation completes.
Referenced by Account(), and Eris::Avatar::onAvatarEntityDeleted().
|
protected |
Destroys the avatar with the specified id, if available.
A check is made if the avatar is registered with the account.
Also emits AvatarDeactivated.
avatarId | The avatar id. |
References _characters, AvatarDeactivated, AvatarFailure, AvatarSuccess, DISCONNECTED, Eris::Avatar::getId(), GotAllCharacters, GotCharacterInfo, LOGGED_IN, LOGGING_IN, LoginFailure, m_con, m_doingCharacterRefresh, m_spawnPoints, and m_status.
Referenced by Eris::Avatar::Avatar(), Eris::Avatar::logoutRequested(), netDisconnecting(), and Eris::Avatar::updateWorldTime().
|
inline |
Gets a list of active characters, i.e.
entities on the server which the account can control.
const CharacterMap & Eris::Account::getCharacters | ( | ) |
Get the characters owned by this account.
Note you should call refreshCharacterInfo, and wait for the GotAllCharacters signal, prior to the initial call : otherwise, it will return an empty or incomplete list.
References _characters, LOGGED_IN, and m_status.
|
inline |
Gets the available spawn points from where the client can create new characters.
References m_spawnPoints.
|
inline |
Return the username of this account.
References m_username.
bool Eris::Account::isLoggedIn | ( | ) | const |
Check if the account is logged in.
Many operations will produce errors if the account is not logged in.
References CREATING_CHAR, DISCONNECTED, Eris::BaseConnection::DISCONNECTING, Eris::Connection::Disconnecting, Eris::getNewSerialno(), Eris::BaseConnection::getStatus(), LOGGED_IN, LOGGING_IN, LOGGING_OUT, LoginSuccess, LogoutComplete, m_accountId, m_con, m_status, m_username, netDisconnecting(), Eris::Connection::send(), TAKING_CHAR, and Eris::Connection::unlock().
Referenced by Account(), Eris::Lobby::join(), Eris::Lobby::Lobby(), and Eris::Lobby::~Lobby().
Result Eris::Account::login | ( | const std::string & | uname, |
const std::string & | pwd | ||
) |
Login to the server using user-supplied account information.
This is the basic way of logging into an existing account. Server-side failures during the login process, such as the account being unknown or an incorrect password being supplied, will result in the 'LoginFailure' signal being emitted with some vaugely helpful error message, and an error code. The LoginSuccess signal will be emitted upon sucessful completion of the login process.
uname | The username of the account |
pwd | The correct password for the account |
References Eris::ALREADY_LOGGED_IN, DISCONNECTED, Eris::BaseConnection::isConnected(), m_con, and m_status.
Result Eris::Account::logout | ( | ) |
Request logout from the server.
Initiate a clean disconnection from the server. The LogoutComplete signal will be emitted when the process completes. Calling this on an Account which is not logged in will produce an error.
References Eris::getNewSerialno(), Eris::BaseConnection::isConnected(), LOGGED_IN, LOGGING_OUT, m_accountId, m_con, m_status, Eris::NOT_LOGGED_IN, and Eris::Connection::send().
Referenced by Account(), and netDisconnecting().
Result Eris::Account::refreshCharacterInfo | ( | ) |
Update the character list (based on changes to play).
The intention here is that clients will call this method for some kind of'choose character' interface or menu, and wait for the GotAllCharacters signal before displaying the list. Alternatively, you can display the UI immediately, and add character entries based on the GotCharacterInfo signal, which will be emitted once for each character.
References _characters, Eris::getNewSerialno(), GotAllCharacters, Eris::BaseConnection::isConnected(), LOGGED_IN, m_accountId, m_con, m_doingCharacterRefresh, m_status, Eris::NOT_LOGGED_IN, and Eris::Connection::send().
Result Eris::Account::takeCharacter | ( | const std::string & | id | ) |
Enter the game using an existing character.
id | The id of the game entity to activate; this must be owned by the account. |
References CREATING_CHAR, Eris::getNewSerialno(), Eris::BaseConnection::isConnected(), LOGGED_IN, m_accountId, m_con, m_status, m_username, Eris::NOT_LOGGED_IN, Eris::Connection::send(), and TAKING_CHAR.
Result Eris::Account::takeTransferredCharacter | ( | const std::string & | id, |
const std::string & | key | ||
) |
Transfer all characters to this account and then do all steps in takeCharacter()
id | The id of the game entity to transfer and activate |
key | The possess_key to authenticate the game entity as ours |
References CREATING_CHAR, Eris::getNewSerialno(), Eris::BaseConnection::isConnected(), LOGGED_IN, m_accountId, m_con, m_status, Eris::NOT_LOGGED_IN, Eris::Connection::send(), and TAKING_CHAR.
sigc::signal<void, Avatar*> Eris::Account::AvatarDeactivated |
Emitted when an active avatar is deactivated.
Clients must not refer to the Avatar or View objects after this signal is emitted (it is safe to access them in a slot connected to this signal)
Referenced by avatarLogoutRequested(), and destroyAvatar().
sigc::signal<void, const std::string &> Eris::Account::AvatarFailure |
Emitted when creating or taking a character fails for some reason.
String argument is the error message from the server.
Referenced by destroyAvatar().
sigc::signal<void, const std::string &> Eris::Account::LoginFailure |
Emitted when a server-side error occurs during account creation / login.
The argument is an error message from the server - hopefully this will become something more useful such as an enum code, in the future.
Referenced by destroyAvatar().
sigc::signal<void> Eris::Account::LoginSuccess |
Emitted when login or character creation is successful.
Referenced by isLoggedIn(), and Eris::Lobby::Lobby().
sigc::signal<void, bool> Eris::Account::LogoutComplete |
Emitted when a logout completes.
Depending on whether the logout completed with a positive server acknowledgment or just timed out, the argument will be either true (success, clean logout) or false (failure, timeout or other problem)
Referenced by isLoggedIn(), Eris::Lobby::Lobby(), and netDisconnecting().
|
protected |
A map of available spawn points.
These are points from which a new avatar can be created.
Referenced by destroyAvatar(), and getSpawnPoints().