eris 1.4.0
A WorldForge client library.
Eris::Account Class Reference

Encapsulates all the state of an Atlas Account, and methods that operation on that state. More...

#include <Account.h>

Inheritance diagram for Eris::Account:
Collaboration diagram for Eris::Account:

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. More...
 
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 CharacterMapgetCharacters ()
 Get the characters owned by this account. More...
 
Result refreshCharacterInfo ()
 
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 createCharacterThroughEntity (const Atlas::Objects::Entity::RootEntity &character)
 enter the game using a new character More...
 
Result createCharacterThroughOperation (const Atlas::Objects::Operation::Create &c)
 
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. entities on the server which the account can control. More...
 
const std::vector< SpawnPoint > & getSpawnPoints () const
 Gets the available spawn points from where the client can create new characters. More...
 
const std::string & getId () const
 returns the account ID if logged in More...
 
const std::string & getUsername () const
 
const std::string & getParent () const
 Gets the parent type of the account. More...
 
ConnectiongetConnection () const
 Access the underlying Connection for this account. More...
 
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 More...
 
sigc::signal< void > GotAllCharacters
 emitted when the entire character list had been updated More...
 
sigc::signal< void, const std::string & > LoginFailure
 Emitted when a server-side error occurs during account creation / login. More...
 
sigc::signal< void > LoginSuccess
 
sigc::signal< void, bool > LogoutComplete
 Emitted when a logout completes. More...
 
sigc::signal< void, Avatar * > AvatarSuccess
 
sigc::signal< void, const std::string & > AvatarFailure
 
sigc::signal< void, const std::string & > AvatarDeactivated
 
sigc::signal< void, const std::string & > ErrorMessage
 

Protected Types

enum class  Status {
  DISCONNECTED = 0 , LOGGING_IN , LOGGED_IN , LOGGING_OUT ,
  TAKING_CHAR , CREATING_CHAR , CREATED_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. More...
 
bool netDisconnecting ()
 help! the plug is being pulled! More...
 
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 (const std::string &avatarId)
 
virtual void updateFromObject (const Atlas::Objects::Entity::Account &p)
 

Protected Attributes

Connectionm_con
 underlying connection instance More...
 
Status m_status
 what the Player is currently doing More...
 
std::unique_ptr< AccountRouterm_router
 
std::string m_accountId
 the account ID More...
 
std::string m_username
 The player's username ( != account object's ID) More...
 
std::string m_pass
 
std::string m_parent
 
CharacterMap _characters
 characters belonging to this player More...
 
std::set< std::string > m_characterIds
 
bool m_doingCharacterRefresh
 set if we're refreshing character data More...
 
ActiveCharacterMap m_activeAvatars
 
std::unique_ptr< TimedEventm_timeout
 
std::vector< SpawnPointm_spawnPoints
 A map of available spawn points. These are points from which a new avatar can be created. More...
 

Friends

class AccountRouter
 
class Avatar
 

Detailed Description

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

Definition at line 42 of file Account.h.

Member Enumeration Documentation

◆ Status

enum class Eris::Account::Status
strongprotected
Enumerator
DISCONNECTED 

Default state, no server account active.

LOGGING_IN 

Login sent, waiting for initial INFO response.

LOGGED_IN 

Fully logged into a server-side account.

LOGGING_OUT 

Sent a logout op, waiting for the INFO response.

TAKING_CHAR 

sent a LOOK op for a character, awaiting INFO response

CREATING_CHAR 

send a character CREATE op, awaiting INFO response

CREATED_CHAR 

a character was created, we now need to possess it

Definition at line 279 of file Account.h.

Constructor & Destructor Documentation

◆ Account()

Eris::Account::Account ( Connection con)
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

Parameters
conA valid (but not necessarily connected) Connection instance

Definition at line 89 of file Account.cpp.

References Eris::BaseConnection::Connected, Eris::Connection::Failure, m_con, and netConnected().

◆ ~Account()

Eris::Account::~Account ( )
virtual

Definition at line 98 of file Account.cpp.

Member Function Documentation

◆ avatarCreateResponse()

void Eris::Account::avatarCreateResponse ( const Atlas::Objects::Operation::RootOperation &  op)
protected

Definition at line 620 of file Account.cpp.

◆ avatarLogoutRequested()

void Eris::Account::avatarLogoutRequested ( Avatar avatar)

Called when a logout of the avatar has been requested by the server.

Note
The avatar instance will be deleted by this method.
Parameters
avatarThe avatar which is being logged out. This instance will be destroyed once this method is done.

Definition at line 418 of file Account.cpp.

References destroyAvatar(), and Eris::Avatar::getId().

◆ avatarLogoutResponse()

void Eris::Account::avatarLogoutResponse ( const Atlas::Objects::Operation::RootOperation &  op)
protected

Definition at line 709 of file Account.cpp.

◆ canCreateCharacter()

bool Eris::Account::canCreateCharacter ( )
inline

pop up the game's character creation dialog, if present

returns true if the game has defined a character creation dialog

Definition at line 317 of file Account.h.

◆ createAccount() [1/2]

Result Eris::Account::createAccount ( const Atlas::Objects::Entity::Account &  accountOp)

Definition at line 144 of file Account.cpp.

◆ createAccount() [2/2]

Result Eris::Account::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.

Definition at line 128 of file Account.cpp.

References createAccount(), and m_username.

Referenced by createAccount().

◆ createCharacterThroughEntity()

Result Eris::Account::createCharacterThroughEntity ( const Atlas::Objects::Entity::RootEntity &  character)

enter the game using a new character

Definition at line 235 of file Account.cpp.

References m_accountId, and m_username.

◆ createCharacterThroughOperation()

Result Eris::Account::createCharacterThroughOperation ( const Atlas::Objects::Operation::Create &  c)

Definition at line 246 of file Account.cpp.

◆ destroyAvatar()

void Eris::Account::destroyAvatar ( const std::string &  avatarId)
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.

Parameters
avatarIdThe avatar id.

Definition at line 422 of file Account.cpp.

References AvatarDeactivated.

Referenced by avatarLogoutRequested(), and Eris::Avatar::logoutRequested().

◆ getActiveCharacters()

const ActiveCharacterMap & Eris::Account::getActiveCharacters ( ) const
inline

Gets a list of active characters, i.e. entities on the server which the account can control.

Returns
A list of active characters on the server which the account can control.

Definition at line 321 of file Account.h.

◆ getCharacters()

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.

Definition at line 194 of file Account.cpp.

References _characters, LOGGED_IN, and m_status.

◆ getConnection()

Connection & Eris::Account::getConnection ( ) const
inline

Access the underlying Connection for this account.

Definition at line 338 of file Account.h.

References m_con.

Referenced by Eris::Avatar::Avatar(), Eris::Lobby::getConnection(), and Eris::Avatar::send().

◆ getId()

const std::string & Eris::Account::getId ( ) const
inline

returns the account ID if logged in

Definition at line 325 of file Account.h.

References m_accountId.

Referenced by Eris::Room::createRoom(), Eris::Room::emote(), Eris::Lobby::join(), Eris::Room::leave(), Eris::Person::msg(), and Eris::Room::say().

◆ getParent()

const std::string & Eris::Account::getParent ( ) const
inline

Gets the parent type of the account.

Definition at line 333 of file Account.h.

◆ getSpawnPoints()

const std::vector< SpawnPoint > & Eris::Account::getSpawnPoints ( ) const
inline

Gets the available spawn points from where the client can create new characters.

Returns
A store of available spawn points.

Definition at line 342 of file Account.h.

References m_spawnPoints.

◆ getUsername()

const std::string & Eris::Account::getUsername ( ) const
inline

Return the username of this account.

Definition at line 329 of file Account.h.

References m_username.

◆ handleLoginTimeout()

void Eris::Account::handleLoginTimeout ( )
protected

Definition at line 560 of file Account.cpp.

◆ handleLogoutTimeout()

void Eris::Account::handleLogoutTimeout ( )
protected

Definition at line 700 of file Account.cpp.

◆ internalDeactivateCharacter()

void Eris::Account::internalDeactivateCharacter ( const std::string &  avatarId)
protected

Definition at line 630 of file Account.cpp.

◆ internalLogin()

Result Eris::Account::internalLogin ( const std::string &  unm,
const std::string &  pwd 
)
protected

Definition at line 329 of file Account.cpp.

◆ internalLogout()

void Eris::Account::internalLogout ( bool  clean)
protected

Definition at line 358 of file Account.cpp.

◆ isLoggedIn()

bool Eris::Account::isLoggedIn ( ) const

Check if the account is logged in.

Many operations will produce errors if the account is not logged in.

Definition at line 324 of file Account.cpp.

References CREATING_CHAR, LOGGED_IN, m_status, and TAKING_CHAR.

Referenced by Eris::Lobby::join(), and Eris::Lobby::Lobby().

◆ login()

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.

Parameters
unameThe username of the account
pwdThe correct password for the account

Definition at line 114 of file Account.cpp.

References Eris::ALREADY_LOGGED_IN, DISCONNECTED, Eris::BaseConnection::isConnected(), m_con, and m_status.

◆ loginComplete()

void Eris::Account::loginComplete ( const Atlas::Objects::Entity::Account &  p)
protected

Definition at line 389 of file Account.cpp.

◆ loginError()

void Eris::Account::loginError ( const Atlas::Objects::Operation::Error &  err)
protected

Definition at line 542 of file Account.cpp.

◆ loginResponse()

void Eris::Account::loginResponse ( const Atlas::Objects::Operation::RootOperation &  op)
protected

Definition at line 379 of file Account.cpp.

◆ logout()

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.

Definition at line 163 of file Account.cpp.

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 netDisconnecting().

◆ logoutResponse()

void Eris::Account::logoutResponse ( const Atlas::Objects::Operation::RootOperation &  op)
protected

Definition at line 351 of file Account.cpp.

◆ netConnected()

void Eris::Account::netConnected ( )
protected

Callback for network re-establishment.

Definition at line 679 of file Account.cpp.

References DISCONNECTED, m_status, and m_username.

Referenced by Account().

◆ netDisconnecting()

bool Eris::Account::netDisconnecting ( )
protected

help! the plug is being pulled!

Definition at line 687 of file Account.cpp.

References Eris::Connection::lock(), LOGGED_IN, logout(), m_con, and m_status.

◆ netFailure()

void Eris::Account::netFailure ( const std::string &  msg)
protected

Definition at line 696 of file Account.cpp.

◆ possessResponse()

void Eris::Account::possessResponse ( const Atlas::Objects::Operation::RootOperation &  op)
protected

Definition at line 567 of file Account.cpp.

◆ refreshCharacterInfo()

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.

Definition at line 201 of file Account.cpp.

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().

◆ sightCharacter()

void Eris::Account::sightCharacter ( const Atlas::Objects::Operation::RootOperation &  op)
protected

Definition at line 639 of file Account.cpp.

◆ takeCharacter()

Result Eris::Account::takeCharacter ( const std::string &  id)

Enter the game using an existing character.

Parameters
idThe id of the game entity to activate; this must be owned by the account.
Returns
The Avatar that represents the character. Note ownership of this passes to the caller.

Definition at line 296 of file Account.cpp.

References CREATED_CHAR, 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.

◆ takeTransferredCharacter()

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()

Parameters
idThe id of the game entity to transfer and activate
keyThe possess_key to authenticate the game entity as ours

Definition at line 267 of file Account.cpp.

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.

◆ updateFromObject()

void Eris::Account::updateFromObject ( const Atlas::Objects::Entity::Account &  p)
protectedvirtual

Definition at line 431 of file Account.cpp.

Friends And Related Function Documentation

◆ AccountRouter

friend class AccountRouter
friend

Definition at line 232 of file Account.h.

◆ Avatar

friend class Avatar
friend

Definition at line 234 of file Account.h.

Member Data Documentation

◆ _characters

CharacterMap Eris::Account::_characters
protected

characters belonging to this player

Definition at line 303 of file Account.h.

Referenced by getCharacters(), and refreshCharacterInfo().

◆ AvatarDeactivated

sigc::signal<void, const std::string &> Eris::Account::AvatarDeactivated

Emitted when an active avatar has been deactivated.

Definition at line 224 of file Account.h.

Referenced by destroyAvatar().

◆ AvatarFailure

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.

Definition at line 219 of file Account.h.

◆ AvatarSuccess

sigc::signal<void, Avatar *> Eris::Account::AvatarSuccess

Emitted when creating a character or taking an existing one succeeds.

Definition at line 213 of file Account.h.

◆ ErrorMessage

sigc::signal<void, const std::string &> Eris::Account::ErrorMessage

Emitted when an error message is received.

Definition at line 229 of file Account.h.

◆ GotAllCharacters

sigc::signal<void> Eris::Account::GotAllCharacters

emitted when the entire character list had been updated

Definition at line 190 of file Account.h.

Referenced by refreshCharacterInfo().

◆ GotCharacterInfo

sigc::signal<void, const Atlas::Objects::Entity::RootEntity &> Eris::Account::GotCharacterInfo

emitted when a character has been retrieved from the server

Definition at line 187 of file Account.h.

◆ LoginFailure

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.

Definition at line 197 of file Account.h.

◆ LoginSuccess

sigc::signal<void> Eris::Account::LoginSuccess

Emitted when login or character creation is successful.

Definition at line 200 of file Account.h.

Referenced by Eris::Lobby::Lobby().

◆ LogoutComplete

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)

Definition at line 207 of file Account.h.

Referenced by Eris::Lobby::Lobby().

◆ m_accountId

std::string Eris::Account::m_accountId
protected

◆ m_activeAvatars

ActiveCharacterMap Eris::Account::m_activeAvatars
protected

Definition at line 307 of file Account.h.

◆ m_characterIds

std::set<std::string> Eris::Account::m_characterIds
protected

Definition at line 304 of file Account.h.

◆ m_con

Connection& Eris::Account::m_con
protected

underlying connection instance

Definition at line 294 of file Account.h.

Referenced by Account(), getConnection(), login(), logout(), netDisconnecting(), refreshCharacterInfo(), takeCharacter(), and takeTransferredCharacter().

◆ m_doingCharacterRefresh

bool Eris::Account::m_doingCharacterRefresh
protected

set if we're refreshing character data

Definition at line 305 of file Account.h.

Referenced by refreshCharacterInfo().

◆ m_parent

std::string Eris::Account::m_parent
protected

Definition at line 302 of file Account.h.

◆ m_pass

std::string Eris::Account::m_pass
protected

Definition at line 300 of file Account.h.

◆ m_router

std::unique_ptr<AccountRouter> Eris::Account::m_router
protected

Definition at line 296 of file Account.h.

◆ m_spawnPoints

std::vector<SpawnPoint> Eris::Account::m_spawnPoints
protected

A map of available spawn points. These are points from which a new avatar can be created.

Definition at line 314 of file Account.h.

Referenced by getSpawnPoints().

◆ m_status

Status Eris::Account::m_status
protected

what the Player is currently doing

Definition at line 295 of file Account.h.

Referenced by getCharacters(), isLoggedIn(), login(), logout(), netConnected(), netDisconnecting(), refreshCharacterInfo(), takeCharacter(), and takeTransferredCharacter().

◆ m_timeout

std::unique_ptr<TimedEvent> Eris::Account::m_timeout
protected

Definition at line 308 of file Account.h.

◆ m_username

std::string Eris::Account::m_username
protected

The player's username ( != account object's ID)

Definition at line 299 of file Account.h.

Referenced by createAccount(), createCharacterThroughEntity(), getUsername(), and netConnected().


The documentation for this class was generated from the following files: