Public Member Functions

PeekabotClient Class Reference

Encapsulates a connection to a peekabot server. More...

List of all members.

Public Member Functions

 PeekabotClient (const PeekabotClient &client)
 Shallow copy construction!
Blocking methods

void connect (const std::string &hostname, unsigned int port=5050)
 Connect the client to a peekabot server.
void disconnect ()
 Disconnect the client from the peekabot server.
void flush ()
 Block until all outbound data has been sent.
void sync ()
 Block until all prior operations have been sent and executed in the peekabot server.
void start_recording (const std::string &filename)
 Record all peekabot operations to the given file. The file can be replayed later using open_recording().
void stop_recording ()
 Stop recording.
Non-blocking methods

void client_version (int &major, int &minor, int &rev) const
 Get the version of the peekabot client library.
const std::string & client_version_str () const
 Get the version of the peekabot client library.
bool is_connected () const
 Returns true if the client is connected to a server, false otherwise.
bool is_recording () const
 Returns true if recording is active, false otherwise.
DelayedDispatch noop ()
 Perform a no-op on the peekabot server.
void begin_bundle ()
 Begin a bundle.
DelayedDispatch end_bundle ()
 End a bundle, for the current thread.
bool is_bundling () const
 Returns true if and only if the client is currently bundling operations for the current thread.
Recording open_recording (const std::string &filename)
DelayedDispatch upload_file (const std::string &filename)
 Upload a client-side file to the peekabot server.
DelayedDispatch remove_file (const std::string &filename)
 Remove a file previously uploaded through upload_file(const std::string &).

Detailed Description

Encapsulates a connection to a peekabot server.


Constructor & Destructor Documentation

PeekabotClient ( const PeekabotClient client  ) 

Shallow copy construction!

Since copy-construction is shallow, the connection, etc. are shared by all copies of the client.


Member Function Documentation

void begin_bundle (  ) 

Begin a bundle.

Any operations issued, in the same thread, between a call to begin_bundle() and end_bundle() are bundled up and sent first when end_bundle() is called. Bundles are thread local, that is, a begin_bundle() call in thread A does not affect bundling in thread B, allowing bundling to be safely used in a multi-threaded setup.

Bundles are atomic in the sense that all the operations contained in the bundle are guaranteed to be executed between two frames. E.g. you won't see strange effects that a newly added object is drawn once before you have the time to set its scale and pose appropriately.

In addition, all operations are guaranteed to execute sequentially "without interruption" - operations from other clients are never interleaved.

See also:
end_bundle(), is_bundling()
void connect ( const std::string &  hostname,
unsigned int  port = 5050 
)

Connect the client to a peekabot server.

Unlike most other client API methods, this particular method is synchronous. It will initiate a connection with the server given, and go through the authentication process before returning.

Operations committed prior to connecting to a server are silently discarded.

Exceptions:
peekabot::client::AlreadyConnected Thrown if the client is already connected.
peekabot::client::AuthenticationFailed Thrown when authentication with the server fails (probably beacause the other end is in fact not a peekabot server, or the server and client are incompatible).
peekabot::client::HostResolveFailed Thrown when the given hostname cannot be resolved.
peekabot::client::ConnectionRefused Thrown when a connection to the host could not be established.
Remarks:
Prior to peekabot 0.6 operations committed before connecting to the server were queued up for transmission when connected.
void disconnect (  ) 

Disconnect the client from the peekabot server.

If the client is not connected, this method is a no-op.

If there's an active bundle, it will be implicitly ended.

Unsent data will be discarded, call flush() or sync() prior to disconnect() to avoid discarding data.

DelayedDispatch end_bundle (  ) 

End a bundle, for the current thread.

Exceptions:
std::runtime_error Thrown if the client currently isn't bundling operations (is_bundling() == false).
void flush (  ) 

Block until all outbound data has been sent.

If the connection is terminated during a call to flush, the method will return, even though not all actions were sent.

bool is_recording (  )  const

Returns true if recording is active, false otherwise.

See also:
start_recording(const std::string &), stop_recording()
DelayedDispatch noop (  ) 

Perform a no-op on the peekabot server.

This is useful for synchronization purposes:

 peekabot::Status s = client.noop().status();
 ...
 s.wait_until_completed();

As illustrated above, this provides, for example, a way to make sure that the data from the last frame was received and processed - this approach, by nature, yields a smaller delay than using sync().

void start_recording ( const std::string &  filename  ) 

Record all peekabot operations to the given file. The file can be replayed later using open_recording().

Exceptions:
std::runtime_error Thrown if recording is already in progress.
See also:
open_recording(const std::string &), stop_recording(), is_recording()
void stop_recording (  ) 

Stop recording.

Exceptions:
std::runtime_error Thrown if recording is not active.
See also:
start_recording(const std::string &), is_recording()
void sync (  ) 

Block until all prior operations have been sent and executed in the peekabot server.

If the connection is terminated during a call to sync, the method will return, even though not all actions were sent or a response received from the server.

Remarks:
sync() will execute immediately, even if there's an active bundle. This behaviour guarantees that the calling application won't hang when syncing inside a bundle.
See also:
flush()
DelayedDispatch upload_file ( const std::string &  filename  ) 

Upload a client-side file to the peekabot server.

After the file has been uploaded, it can be used as any other file. Uploaded client-side files always have precedence over server-side files. Files uploaded by one client cannot be used by another, and any uploaded files are discarded when the client disconnects.

Exceptions:
std::runtime_error If there is an error reading the file.

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