next up previous contents
Next: 2.4 BlobfinderProxy Up: 2. Class Reference Previous: 2.2 PlayerMultiClient   Contents


2.3 ClientProxy

Base class for all proxy devices. Access to a device is provided by a device-specific proxy class. These classes all inherit from the ClientProxy class which defines an interface for device proxies. As such, a few methods are common to all devices and we explain them here.


PlayerClient* client;

The controlling client object.

bool valid;

Have we yet received any data from this device?

char driver_name[PLAYER_MAX_DEVICE_STRING_LEN]; // driver in use

The name of the driver used to implement this device in the server.

struct timeval timestamp;

Time at which this data was generated by the device.

struct timeval senttime;

Time at which this data was sent by the server.

struct timeval receivedtime;

Time at which this data was received by the client.


ClientProxy(PlayerClient* pc,
unsigned short req_device,
unsigned short req_index,
unsigned char req_access = 'c')

This constructor will try to get access to the device, unless req_device is 0 or req_access is 'c'. The pointer pc must refer to an already connected PlayerClient proxy. The index indicates which one of the devices to use (usually 0). Note that a request executed by this the constructor can fail, but the constructor cannot indicate the failure. Thus, if you request a particular access mode, you should verify that the current access is identical to your requested access using GetAccess(). In any case, you can use ChangeAccess() later to change your access mode for the device.

unsigned char GetAccess()

Returns the current access mode for the device.

int ChangeAccess(unsigned char req_access,
unsigned char* grant_access=NULL )

Request different access for the device. If grant_access is non-NULL, then it is filled in with the granted access. Returns 0 on success, -1 otherwise.

int Close()

Convenience method for requesting 'c' access.

virtual void FillData(player_msghdr_t hdr, const char* buffer)

All proxies must provide this method. It is used internally to parse new data when it is received.

void StoreData(player_msghdr_t hdr, const char* buffer)

This method is used internally to keep a copy of the last message from the device *

virtual void Print()

All proxies SHOULD provide this method, which should print out, in a human-readable form, the device's current state.

next up previous contents
Next: 2.4 BlobfinderProxy Up: 2. Class Reference Previous: 2.2 PlayerMultiClient   Contents