AccountConnection Class Reference

A connection to the account server. More...

#include <accountconnection.hpp>

Inheritance diagram for AccountConnection:

Connection

List of all members.

Public Member Functions

 AccountConnection ()
 Constructor.
 ~AccountConnection ()
 Destructor.
bool start ()
 Initializes a connection to the account server described in the configuration file.
void sendCharacterData (Character *)
 Sends data of a given character.
void playerReconnectAccount (int id, const std::string &magic_token)
 Prepares the account server for a reconnecting player.
void requestQuestVar (Character *, const std::string &)
 Requests the value of a quest variable from the database.
void updateQuestVar (Character *, const std::string &name, const std::string &value)
 Pushes a new quest value to the database.
void banCharacter (Character *, int)
 Sends ban message.
void sendStatistics ()
 Gathers statistics and sends them.
void sendPost (Character *, MessageIn &)
 Send letter.
void getPost (Character *)
 Get post.
void changeAccountLevel (Character *, int)
 Change Account Level.
void syncChanges (bool force=false)
 Sends all changed player data to the account server to minimize dataloss due to failure of one server component.
void updateCharacterPoints (int charId, int charPoints, int corrPoints, int attribId, int attribValue)
 Write a modification message about character points to the sync buffer.
void updateExperience (int charId, int skillId, int skillValue)
 Write a modification message about character skills to the sync buffer.
void updateOnlineStatus (int charId, bool online)
 Update the status of a character to online (true) or offline (false).
void sendTransaction (int id, int action, const std::string &message)
 Send transaction to account server.

Protected Member Functions

virtual void processMessage (MessageIn &)
 Processes server messages.


Detailed Description

A connection to the account server.

Definition at line 49 of file accountconnection.hpp.


Member Function Documentation

bool AccountConnection::start (  ) 

Initializes a connection to the account server described in the configuration file.

Registers the maps known by MapManager.

Definition at line 51 of file accountconnection.cpp.

References Connection::send(), Connection::start(), MessageOut::writeLong(), MessageOut::writeShort(), and MessageOut::writeString().

void AccountConnection::syncChanges ( bool  force = false  ) 

Sends all changed player data to the account server to minimize dataloss due to failure of one server component.

The gameserver holds a buffer with all changes made by a character.

Parameters:
force Send changes even if buffer hasn't reached its size or message limit. (used to send in timed schedules)
The changes are added at the time they occur. When the buffer reaches one of the following limits, the buffer is sent to the account server and applied to the database.

The sync buffer is sent when:

  • forced by any process (param force = true)
  • every 10 seconds
  • buffer reaches size of 1kb (defined in SYNC_BUFFER_SIZE)
  • buffer holds more then 20 messages (defined in SYNC_BUFFER_LIMIT)

Definition at line 315 of file accountconnection.cpp.

References MessageOut::getLength(), Connection::send(), and MessageOut::writeByte().

Referenced by updateCharacterPoints(), updateExperience(), and updateOnlineStatus().

void AccountConnection::updateCharacterPoints ( int  charId,
int  charPoints,
int  corrPoints,
int  attribId,
int  attribValue 
)

Write a modification message about character points to the sync buffer.

Parameters:
charId ID of the character
charPoints character points left for the character
corrPoints correction points left for the character
attribId ID of the modified attribute
attribValue New value of the modified attribute

Definition at line 346 of file accountconnection.cpp.

References syncChanges(), MessageOut::writeByte(), and MessageOut::writeLong().

Referenced by GameHandler::processMessage().

void AccountConnection::updateExperience ( int  charId,
int  skillId,
int  skillValue 
)

Write a modification message about character skills to the sync buffer.

Parameters:
charId ID of the character
skillId ID of the skill
skillValue new skill points

Definition at line 361 of file accountconnection.cpp.

References syncChanges(), MessageOut::writeByte(), and MessageOut::writeLong().

Referenced by Character::receiveExperience().

void AccountConnection::updateOnlineStatus ( int  charId,
bool  online 
)

Update the status of a character to online (true) or offline (false).

Parameters:
charId Id of the character.
online True to flag the character as being online.

Definition at line 372 of file accountconnection.cpp.

References syncChanges(), MessageOut::writeByte(), and MessageOut::writeLong().


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

Generated on Sun Apr 26 17:30:46 2009 for TMW Server Collection by  doxygen 1.5.5