Advanced Strategic Command
Public Member Functions | Static Public Attributes | List of all members
ASC_PBEM Class Reference

#include <pbem-server-interaction.h>

Inheritance diagram for ASC_PBEM:
Inheritance graph
[legend]

Public Member Functions

 ASC_PBEM (ASCString serverBase)
 default constructor: More...
 
 ~ASC_PBEM ()
 
bool isUsable ()
 important: check this first after instantiation this class will be false after any More...
 
bool login (ASCString user, ASCString passwd)
 
bool createAccount (ASCString user, ASCString passwd, ASCString email)
 
bool activateAccount (ASCString user, ASCString code)
 
bool uploadFile (ASCString fileName, const Uint8 *data, const int size, const int gameID)
 
std::vector< TUserDatagetUserList (bool activeOnly=true)
 
bool createGame (ASCString fileName, const Uint8 *data, const int size, ASCString gameName, ASCString fileNamePattern, char *roles, int *players, int projectID=-1, int turn=1, int currentSlot=1)
 
std::vector< TGameInfogetCurrentGamesInfo (bool myTurnOnly)
 
TFileDatadownloadGame (TGameInfo game)
 
bool logout ()
 
bool isLoggedIn ()
 
ASCString getHeader ()
 
ASCString getBody ()
 
int getStatusCode ()
 
std::vector< ASCStringlistPlayers ()
 
- Public Member Functions inherited from ServerInterface
std::vector< ASCStringlistPlayers ()
 

Static Public Attributes

static const char ROLE_SUPERVISOR = 's'
 
static const char ROLE_PLAYER = 'p'
 
static const char ROLE_HIDDEN = 'h'
 

Detailed Description

Definition at line 106 of file pbem-server-interaction.h.

Constructor & Destructor Documentation

ASC_PBEM::ASC_PBEM ( ASCString  serverBase)

default constructor:

Parameters
serverBasedefault url syntax, example: http://localhost:8080/ascServer/ note: currently, the trailing slash is required ??? todo: fix that ;)

Definition at line 150 of file pbem-server-interaction.cpp.

ASC_PBEM::~ASC_PBEM ( )

Definition at line 180 of file pbem-server-interaction.cpp.

Member Function Documentation

bool ASC_PBEM::activateAccount ( ASCString  user,
ASCString  code 
)
Returns
true if the account could be activated false if anything went wrong, which is most likely due to one of these reasons:
  • wrong server
  • wrong code

Definition at line 417 of file pbem-server-interaction.cpp.

bool ASC_PBEM::createAccount ( ASCString  user,
ASCString  passwd,
ASCString  email 
)
Returns
true if the account could be created false if anything went wrong, which is most likely due to one of these reasons:
  • wrong server
  • username already taken
  • invalid characters for either username or password

Definition at line 398 of file pbem-server-interaction.cpp.

bool ASC_PBEM::createGame ( ASCString  fileName,
const Uint8 *  data,
const int  size,
ASCString  gameName,
ASCString  fileNamePattern,
char *  roles,
int *  players,
int  projectID = -1,
int  turn = 1,
int  currentSlot = 1 
)
TFileData * ASC_PBEM::downloadGame ( TGameInfo  game)
Returns
the file data of a ascpbm game, or NULL if not logged in or an error occured

Definition at line 610 of file pbem-server-interaction.cpp.

References ASC_PBEM_writeBuffer(), TGameInfo::currentSaveGameName, TFileData::fileData, TFileData::fileName, TFileData::fileSize, TGameInfo::gameID, and getBody().

ASCString ASC_PBEM::getBody ( )

Definition at line 697 of file pbem-server-interaction.cpp.

Referenced by downloadGame(), getCurrentGamesInfo(), getUserList(), and nmain().

std::vector< TGameInfo > ASC_PBEM::getCurrentGamesInfo ( bool  myTurnOnly)
Returns
a vector of TGameInfo structs containing the current games of the logged in player
Parameters
myTurnOnlyif true, only return info about games where it's the turn of the currenty logged in player

Definition at line 511 of file pbem-server-interaction.cpp.

References getBody(), and line().

Referenced by nmain().

ASCString ASC_PBEM::getHeader ( )

Definition at line 689 of file pbem-server-interaction.cpp.

Referenced by nmain().

int ASC_PBEM::getStatusCode ( )

Definition at line 705 of file pbem-server-interaction.cpp.

Referenced by nmain().

std::vector< TUserData > ASC_PBEM::getUserList ( bool  activeOnly = true)
Returns
a vector of TUserData structs containing the ascpbem server accounts
Parameters
activeOnlyif true, only return data about active (activated) players

Definition at line 555 of file pbem-server-interaction.cpp.

References getBody(), and line().

Referenced by listPlayers().

bool ASC_PBEM::isLoggedIn ( )

Definition at line 190 of file pbem-server-interaction.cpp.

bool ASC_PBEM::isUsable ( )

important: check this first after instantiation this class will be false after any

See Also
request where anything went wrong if false, no request will be send out again, and this instance is basically done for

Definition at line 185 of file pbem-server-interaction.cpp.

Referenced by nmain().

std::vector< ASCString > ASC_PBEM::listPlayers ( )

Definition at line 597 of file pbem-server-interaction.cpp.

References getUserList().

bool ASC_PBEM::login ( ASCString  user,
ASCString  passwd 
)
Returns
true if login to pbem server procceded ok, false if anything went wrong (most likely wrong user/password, but could also be wrong server base or inactive account

Definition at line 381 of file pbem-server-interaction.cpp.

Referenced by PBEMServer::getSession(), and nmain().

bool ASC_PBEM::logout ( )
Returns
true if logout went ok, false on failure failure most likely means one of two things:
  • wrong server url
  • not logged in (session timeout?)

Definition at line 367 of file pbem-server-interaction.cpp.

Referenced by nmain().

bool ASC_PBEM::uploadFile ( ASCString  fileName,
const Uint8 *  data,
const int  size,
const int  gameID 
)

Member Data Documentation

const char ASC_PBEM::ROLE_HIDDEN = 'h'
static

Definition at line 134 of file pbem-server-interaction.h.

const char ASC_PBEM::ROLE_PLAYER = 'p'
static

Definition at line 133 of file pbem-server-interaction.h.

const char ASC_PBEM::ROLE_SUPERVISOR = 's'
static

Definition at line 132 of file pbem-server-interaction.h.


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