PlayerCc::PlayerClient Class Reference
[Core functionality]
#include <playerclient.h>
Detailed Description
The PlayerClient is used for communicating with the player server.One PlayerClient object is used to control each connection to a Player server. Contained within this object are methods for changing the connection parameters and obtaining access to devices.
Since the threading functionality of the PlayerClient is built on Boost, these options are conditionally available based on the Boost threading library being present on the system. The StartThread() and StopThread() are the only functions conditionally available based on this.
Public Member Functions | |
PlayerClient (const std::string aHostname=PLAYER_HOSTNAME, uint aPort=PLAYER_PORTNUM) | |
Make a client and connect it as indicated. | |
~PlayerClient () | |
destructor | |
void | StartThread () |
Start the run thread. | |
void | StopThread () |
Stop the run thread. | |
void | Run (uint aTimeout=10) |
This starts a blocking loop on Read(). | |
void | Stop () |
Stops the Run() loop. | |
bool | Peek (uint timeout=0) |
Check whether there is data waiting on the connection, blocking for up to timeout milliseconds (set to 0 to not block). - false if there is no data waiting - true if there is data waiting. | |
void | Read () |
A blocking Read Use this method to read data from the server, blocking until at least one message is received. Use PlayerClient::Peek() to check whether any data is currently waiting. In pull mode, this will block until all data waiting on the server has been received, ensuring as up to date data as possible. | |
void | ReadIfWaiting () |
A nonblocking Read Use this method if you want to read in a nonblocking manner. This is the equivalent of checking if Peek is true and then reading. | |
void | SetDataMode (uint aMode) |
You can toggle the mode in which the server sends data to your client with this method. The mode should be one of - PLAYER_DATAMODE_PUSH (all data) - PLAYER_DATAMODE_PULL (data on demand) When in pull mode, it is highly recommended that a replace rule is set for data packets to prevent the server message queue becoming flooded. throws PlayerError if unsuccessfull. | |
void | SetReplaceRule (int aInterf, int aIndex, int aType, int aSubtype, int aReplace) |
Set a replace rule for the clients queue on the server. If a rule with the same pattern already exists, it will be replaced with the new rule (i.e., its setting to replace will be updated). aInterf Interface to set replace rule for (-1 for wildcard) aIndex index to set replace rule for (-1 for wildcard) aType type to set replace rule for (-1 for wildcard), i.e. PLAYER_MSGTYPE_DATA aSubtype message subtype to set replace rule for (-1 for wildcard) aReplace Should we replace these messages Returns 0 on success, non-zero otherwise. Use throws PlayerError if unsuccessfull. | |
void | RequestDeviceList () |
Get the list of available device ids. The data is written into the proxy structure rather than retured to the caller. | |
std::list< playerc_device_info_t > | GetDeviceList () |
std::string | GetHostname () const |
Returns the hostname. | |
uint | GetPort () const |
Returns the port. | |
int | LookupCode (std::string aName) const |
Get the interface code for a given name. | |
std::string | LookupName (int aCode) const |
Get the name for a given interface code. | |
Public Attributes | |
mutex_t | mMutex |
A mutex for handling synchronization. |
The documentation for this class was generated from the following file: