#include <gamelayer.h>
Public Member Functions | |
| GameLayer () | |
| Constructs object and sets up defaults. | |
| ~GameLayer () | |
| Destructor. | |
| void | setClientString (const std::string &name) |
| Sets the client string. | |
| void | setLogger (Logger *nlog) |
| Sets the Logger to use. | |
| void | setGameStatusListener (GameStatusListener *gsl) |
| Sets the GameStatusListener to use. | |
| void | setCacheMethod (CacheMethod *prototype) |
| Sets the CacheMethod for the caches to use. Changes the default CacheMethod used, defaults to CacheNoneMethod. | |
| void | setEventLoop (EventLoop *el) |
| Sets the EventLoop abstraction to use. Sets which implementation of EventLoop to use. | |
| GameStatus | getStatus () |
| Gets the state of the game. | |
| ProtocolLayer * | getProtocolLayer () const |
| Gets the ProtocolLayer being used. This could be used to do low level calls to the protocol itself, or more importantly, set the FrameFactory, FrameBuilder and/or FrameCodec classes in the ProtocolLayer. | |
| bool | connect (const std::string &address) |
| Connects to the given address url This method connects to the server given as the address. The types of url supported are tp, tps, https and http. Tps and https depend on TLS being enabled. | |
| bool | connect (TPSocket *nsock) |
| Connects using a given TPSocket. Connects to a server using a given TPSocket. | |
| bool | createAccount (const std::string &user, const std::string &password, const std::string &email, const std::string &comment) |
| Creates an account on the server. | |
| bool | login (const std::string &user, const std::string &password) |
| Logs in to the server. | |
| void | disconnect () |
| Disconnects from server. | |
| void | updateCaches () |
| Tells all the caches to update. Called automatically after logged in, and after EOT has finished. Call if you want the caches to be updated. | |
| ObjectDescCache * | getObjectDescCache () const |
| Gets the ObjectDescCache. | |
| ObjectCache * | getObjectCache () const |
| Gets the ObjectCache. | |
| OrderDescCache * | getOrderDescCache () const |
| Gets the OrderDescCache. | |
| std::list< Order * > | getOrders (uint32_t obid, uint32_t num) |
| Gets Orders from the server. | |
| Order * | getOrder (uint32_t obid, uint32_t slot) |
| Gets an Orders from the server. | |
| Order * | createOrderFrame (int type) |
| Creates an Order Frame of a given type. | |
| bool | insertOrder (Order *frame) |
| Inserts an Order into the objects order queue. | |
| bool | replaceOrder (Order *frame) |
| Replaces a current Order with a new one. | |
| Order * | probeOrder (Order *frame) |
| Probes an Order. | |
| bool | removeOrder (uint32_t obid, uint32_t slot) |
| Removes an Order from the server. | |
| BoardCache * | getBoardCache () const |
| Gets the BoardCache. | |
| std::list< Message * > | getMessages (uint32_t boardid, uint32_t num) |
| Gets Messages from the server. | |
| Message * | createMessage () |
| Creates a Message object. | |
| Message * | getMessage (uint32_t boardid, uint32_t slot) |
| Gets a Message from the server. | |
| bool | postMessage (Message *frame) |
| Posts a Message to the server. | |
| bool | removeMessage (uint32_t boardid, uint32_t slot) |
| Removes messages from the server. | |
| ResourceCache * | getResourceCache () const |
| Gets the ResourceCache. | |
| PlayerCache * | getPlayerCache () const |
| Gets the PlayerCache. | |
| CategoryCache * | getCategoryCache () const |
| Gets the CategoryCache. | |
| DesignCache * | getDesignCache () const |
| Gets the DesignCache. | |
| ComponentCache * | getComponentCache () const |
| Gets the ComponentCache. | |
| PropertyCache * | getPropertyCache () const |
| Gets the PropertyCache. | |
| void | getTimeRemaining () |
| Gets the time remaining before the end of turn. | |
| void | finishedTurn () |
Friends | |
| class | GameLayerAsyncFrameListener |
GameLayer abstracts away most of the underlying details of how Objects and Orders are requested and received.
| TPProto::GameLayer::GameLayer | ( | ) |
Constructs object and sets up defaults.
Defaults are
| void TPProto::GameLayer::setClientString | ( | const std::string & | name | ) |
Sets the client string.
The client string can be set to anything. The perferred format is "name/version". The library name and version is added the the client string later.
| name | The client name string. |
| void TPProto::GameLayer::setLogger | ( | Logger * | nlog | ) |
| void TPProto::GameLayer::setGameStatusListener | ( | GameStatusListener * | gsl | ) |
| void TPProto::GameLayer::setCacheMethod | ( | CacheMethod * | prototype | ) |
Sets the CacheMethod for the caches to use. Changes the default CacheMethod used, defaults to CacheNoneMethod.
| prototype | A CacheMethod that will be cloned for each Cache to use. |
| void TPProto::GameLayer::setEventLoop | ( | EventLoop * | el | ) |
| GameStatus TPProto::GameLayer::getStatus | ( | ) |
Gets the state of the game.
| ProtocolLayer * TPProto::GameLayer::getProtocolLayer | ( | ) | const |
Gets the ProtocolLayer being used. This could be used to do low level calls to the protocol itself, or more importantly, set the FrameFactory, FrameBuilder and/or FrameCodec classes in the ProtocolLayer.
| bool TPProto::GameLayer::connect | ( | const std::string & | address | ) |
Connects to the given address url This method connects to the server given as the address. The types of url supported are tp, tps, https and http. Tps and https depend on TLS being enabled.
| address | The URL to connect to. |
| bool TPProto::GameLayer::connect | ( | TPSocket * | nsock | ) |
| bool TPProto::GameLayer::createAccount | ( | const std::string & | user, | |
| const std::string & | password, | |||
| const std::string & | email, | |||
| const std::string & | comment | |||
| ) |
Creates an account on the server.
Sends a AccountCreate Frame to the server and waits for a reply.
| user | The username to use. | |
| password | The password for the account. | |
| The user's email address. | ||
| comment | A comment to send. |
| bool TPProto::GameLayer::login | ( | const std::string & | username, | |
| const std::string & | password | |||
| ) |
| void TPProto::GameLayer::disconnect | ( | ) |
Disconnects from server.
Closes the underlying TPSocket.
| ObjectDescCache * TPProto::GameLayer::getObjectDescCache | ( | ) | const |
| ObjectCache * TPProto::GameLayer::getObjectCache | ( | ) | const |
| OrderDescCache * TPProto::GameLayer::getOrderDescCache | ( | ) | const |
| std::list< Order * > TPProto::GameLayer::getOrders | ( | uint32_t | obid, | |
| uint32_t | num | |||
| ) |
| Order * TPProto::GameLayer::getOrder | ( | uint32_t | obid, | |
| uint32_t | slot | |||
| ) |
| Order * TPProto::GameLayer::createOrderFrame | ( | int | type | ) |
| bool TPProto::GameLayer::insertOrder | ( | Order * | frame | ) |
| bool TPProto::GameLayer::replaceOrder | ( | Order * | frame | ) |
| bool TPProto::GameLayer::removeOrder | ( | uint32_t | obid, | |
| uint32_t | slot | |||
| ) |
Removes an Order from the server.
Sends the RemoveOrder frame to the server and receives reply.
| obid | The Object to remove the order from. | |
| slot | The slot that should have it's order removed. |
| BoardCache * TPProto::GameLayer::getBoardCache | ( | ) | const |
| std::list< Message * > TPProto::GameLayer::getMessages | ( | uint32_t | boardid, | |
| uint32_t | num | |||
| ) |
Gets Messages from the server.
Sends the GetMessage Frame and receives the Message frames.
| boardid | The board ID of the board to get the messages from. | |
| num | The number of messages to get. |
| Message * TPProto::GameLayer::createMessage | ( | ) |
| Message * TPProto::GameLayer::getMessage | ( | uint32_t | boardid, | |
| uint32_t | slot | |||
| ) |
Gets a Message from the server.
Sends the GetMessage Frame and receives the Message frame.
| boardid | The board ID of the board to get the message from. | |
| slot | The slot number of the message to get. |
| bool TPProto::GameLayer::postMessage | ( | Message * | frame | ) |
| bool TPProto::GameLayer::removeMessage | ( | uint32_t | boardid, | |
| uint32_t | slot | |||
| ) |
Removes messages from the server.
Sends the RemoveMessage frame and receives the replies.
| boardid | The board id of the board to remove the message from. | |
| slot | The slot to remove the message from. |
| ResourceCache * TPProto::GameLayer::getResourceCache | ( | ) | const |
| PlayerCache * TPProto::GameLayer::getPlayerCache | ( | ) | const |
| CategoryCache * TPProto::GameLayer::getCategoryCache | ( | ) | const |
| DesignCache * TPProto::GameLayer::getDesignCache | ( | ) | const |
| ComponentCache * TPProto::GameLayer::getComponentCache | ( | ) | const |
| PropertyCache * TPProto::GameLayer::getPropertyCache | ( | ) | const |
| void TPProto::GameLayer::getTimeRemaining | ( | ) |
Gets the time remaining before the end of turn.
Fetches the time remaining till the end of turn from the server. The actual value is returned through the GameStatusListener::timeToEoT().
1.5.1