Encapsulates a connection to a peekabot server. More...
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 &). | |
Encapsulates a connection to a peekabot server.
| PeekabotClient | ( | const PeekabotClient & | client | ) |
Shallow copy construction!
Since copy-construction is shallow, the connection, etc. are shared by all copies of the client.
| 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.
| 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.
| 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. |
| 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.
| 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.
| 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().
| std::runtime_error | Thrown if recording is already in progress. |
| void stop_recording | ( | ) |
Stop recording.
| std::runtime_error | Thrown if recording is not active. |
| 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.
| 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.
| std::runtime_error | If there is an error reading the file. |
1.7.1