Ocean
|
This class implements a streaming client. More...
Public Types | |
typedef Callback< bool, const State, const std::string & > | RequestCallback |
Definition of a callback function for streaming server requests. More... | |
typedef Callback< void, const void *, const size_t > | ReceiveCallback |
Definition of a callback function for streaming data. More... | |
typedef std::vector< std::string > | Channels |
Definition of a vector holding channels. More... | |
Public Types inherited from Ocean::Network::Streaming | |
enum | State { STATE_START , STATE_PAUSE , STATE_STOP , STATE_TYPE_CHANGED } |
Definition of different streaming states. More... | |
typedef MessageQueue::Id | SessionId |
Definition of a session id. More... | |
Public Member Functions | |
StreamingClient () | |
Creates a new streaming client. More... | |
~StreamingClient () | |
Destructs a streaming client. More... | |
bool | connect (const Address4 &address, const Port &port) |
Connects the streaming client with a remote streaming server. More... | |
bool | disconnect () |
Disconnects the streaming client. More... | |
bool | isConnected () const |
Returns whether this client is currently connected with a streaming server. More... | |
Channels | selectableChannels () |
Returns a list of selectable channels provides by the streaming server. More... | |
std::string | channelDataType (const std::string &channel) |
Returns a data type of a specified channel provides by the streaming server. More... | |
const std::string & | channel () const |
Returns the selected channel of the streaming server. More... | |
const std::string & | dataType () const |
Returns the type of the streaming data. More... | |
const Address4 & | serverAddress () const |
Returns the address of the connected streaming server. More... | |
const Port & | serverPort () const |
Returns the port of the connected streaming server. More... | |
bool | start (const std::string &channel=std::string()) |
(Re-)Starts the streaming. More... | |
bool | pause () |
Pauses the streaming. More... | |
bool | stop () |
Stops the streaming. More... | |
bool | isReceiving () |
Returns whether this client is currently receiving streaming data. More... | |
bool | isPaused () |
Returns whether this client is currently paused. More... | |
void | setRequestCallback (const RequestCallback &callback) |
Sets the callback function for streaming server requests (like e.g. More... | |
void | setReceiveCallback (const ReceiveCallback &callback) |
Sets the callback function for streaming data received from the streaming server. More... | |
Public Member Functions inherited from Ocean::Network::Streaming | |
const std::string & | name () const |
Returns the name of this streaming object. More... | |
const std::string & | description () const |
Returns the description of this streaming object. More... | |
double | responseTimeout () const |
Returns the timeout value the streaming object waits for response messages. More... | |
virtual bool | setName (const std::string &name) |
Sets the name of this streaming object. More... | |
virtual bool | setDescription (const std::string &description) |
Sets the description of this streaming object. More... | |
bool | setResponseTimeout (const double timeout) |
Sets the timeout value the streaming object waits for response messages. More... | |
Protected Member Functions | |
void | onCommand (const std::string &command, const std::string &value, const SessionId sessionId) |
New command function. More... | |
void | onStart (const std::string &value, const SessionId sessionId) |
Function handling start commands. More... | |
void | onPause (const std::string &value, const SessionId sessionId) |
Function handling pause commands. More... | |
void | onStop (const std::string &value, const SessionId sessionId) |
Function handling stop commands. More... | |
void | onChangedDataType (const std::string &value, const SessionId sessionId) |
Function handling changed data type commands. More... | |
void | onTCPReceiveData (const void *data, const size_t size) |
Callback function for TCP receive message. More... | |
void | onUDPReceiveData (const Address4 &address, const Port &port, const void *data, const size_t size, const PackagedSocket::MessageId messageId) |
Callback function for UDP receive message. More... | |
Protected Member Functions inherited from Ocean::Network::Streaming | |
Streaming () | |
Creates a new streaming object. More... | |
Streaming (const Streaming &streaming)=delete | |
Disabled copy constructor. More... | |
virtual | ~Streaming ()=default |
Destructs an object. More... | |
bool | parse (const unsigned char *data, const size_t size, bool &isResponse, std::string &message, std::string &value, SessionId &sessionId) |
Parses a command or a response. More... | |
Streaming & | operator= (const Streaming &streaming)=delete |
Disabled copy operator. More... | |
Protected Attributes | |
std::string | channel_ |
Stream channel. More... | |
std::string | dataType_ |
Stream data type. More... | |
bool | isReceiving_ = false |
Determines whether the client is currently receiving. More... | |
bool | isPaused_ = false |
Determines whether the client is pause. More... | |
PackagedUDPServer | udpClient_ |
UDP client. More... | |
TCPClient | tcpClient_ |
TCP client. More... | |
Address4 | serverAddress_ |
Address4 of the streaming server. More... | |
Port | serverPort_ |
Port of the streaming server. More... | |
RequestCallback | requestCallback_ |
Streaming server request callback function. More... | |
ReceiveCallback | receiveCallback_ |
Streaming data receive callback function. More... | |
Lock | lock_ |
Client lock. More... | |
Protected Attributes inherited from Ocean::Network::Streaming | |
std::string | name_ |
Name of this streaming object. More... | |
std::string | description_ |
Description of this streaming object. More... | |
double | responseTimeout_ = 2.0 |
Timeout value for response messages. More... | |
MessageQueue | messageQueue_ = MessageQueue(100) |
Message queue. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Ocean::Network::Streaming | |
static const std::string & | connectCommand () |
Definition of a connect command. More... | |
static const std::string & | connectResponseP () |
Definition of a positive connect response. More... | |
static const std::string & | connectResponseN () |
Definition of a negative connect response. More... | |
static const std::string & | disconnectCommand () |
Definition of a disconnect command. More... | |
static const std::string & | disconnectResponseP () |
Definition of a positive disconnect response. More... | |
static const std::string & | disconnectResponseN () |
Definition of a negative disconnect response. More... | |
static const std::string & | channelSelectCommand () |
Definition of a channel select command. More... | |
static const std::string & | channelSelectResponseP () |
Definition of a positive channel select response. More... | |
static const std::string & | channelSelectResponseN () |
Definition of a negative channel select response. More... | |
static const std::string & | startCommand () |
Definition of a start command. More... | |
static const std::string & | startResponseP () |
Definition of a positiv start response. More... | |
static const std::string & | startResponseN () |
Definition fo a negative start response. More... | |
static const std::string & | pauseCommand () |
Definition of a pause command. More... | |
static const std::string & | pauseResponseP () |
Definition of a positive pause response. More... | |
static const std::string & | pauseResponseN () |
Definition of a negative pause response. More... | |
static const std::string & | stopCommand () |
Definition of a stop command. More... | |
static const std::string & | stopResponseP () |
Definition of a positive stop response. More... | |
static const std::string & | stopResponseN () |
Definition of a negative stop response. More... | |
static const std::string & | clientPortCommand () |
Definition of a client port command. More... | |
static const std::string & | clientPortResponseP () |
Definition of a positive client port response. More... | |
static const std::string & | clientPortResponseN () |
Definition of a negative client port response. More... | |
static const std::string & | serverPortCommand () |
Definition of a server port command. More... | |
static const std::string & | serverPortResponseP () |
Definition of a positive server port response. More... | |
static const std::string & | serverPortResponseN () |
Definition of a negative server port response. More... | |
static const std::string & | channelRequestCommand () |
Definition of a channel request command. More... | |
static const std::string & | channelRequestResponseP () |
Definition of a positive channel request response. More... | |
static const std::string & | channelRequestResponseN () |
Definition of a negative channel request response. More... | |
static const std::string & | changedDataTypeCommand () |
Definition of a changed data type command. More... | |
static const std::string & | changedDataTypeResponseP () |
Definition of a positive changed data type request. More... | |
static const std::string & | changedDataTypeResponseN () |
Definition of a negative change data type request. More... | |
static const std::string & | dataTypeRequestCommand () |
Definition of a data type request command. More... | |
static const std::string & | dataTypeRequestResponseP () |
Definition of a positive data type request response. More... | |
static const std::string & | dataTypeRequestResponseN () |
Definition of a negative data type request response. More... | |
static std::string | createCommand (const std::string &command, const SessionId sessionId) |
Creates a new command message. More... | |
static std::string | createCommand (const std::string &command, const std::string &value, const SessionId sessionId) |
Creates a new command message with a value. More... | |
static std::string | createResponse (const std::string &response, const SessionId sessionId) |
Creates a new response message. More... | |
static std::string | createResponse (const std::string &response, const std::string &value, const SessionId sessionId) |
Creates a new response message with a value. More... | |
This class implements a streaming client.
The client uses a TCP connection for configuration tasks and a UDP connection for the data transfer.
typedef std::vector<std::string> Ocean::Network::StreamingClient::Channels |
Definition of a vector holding channels.
typedef Callback<void, const void*, const size_t> Ocean::Network::StreamingClient::ReceiveCallback |
Definition of a callback function for streaming data.
Parameter 0 provides the buffer that has been received Parameter 1 provides the size of the buffer, in bytes
typedef Callback<bool, const State, const std::string&> Ocean::Network::StreamingClient::RequestCallback |
Definition of a callback function for streaming server requests.
Ocean::Network::StreamingClient::StreamingClient | ( | ) |
Creates a new streaming client.
Ocean::Network::StreamingClient::~StreamingClient | ( | ) |
Destructs a streaming client.
|
inline |
Returns the selected channel of the streaming server.
std::string Ocean::Network::StreamingClient::channelDataType | ( | const std::string & | channel | ) |
Returns a data type of a specified channel provides by the streaming server.
channel | Channel to return the data type for |
|
inline |
Returns the type of the streaming data.
bool Ocean::Network::StreamingClient::disconnect | ( | ) |
Disconnects the streaming client.
bool Ocean::Network::StreamingClient::isConnected | ( | ) | const |
Returns whether this client is currently connected with a streaming server.
|
inline |
Returns whether this client is currently paused.
|
inline |
Returns whether this client is currently receiving streaming data.
Beware: If the client is paused the client still is handled as in receiving mode.
|
protected |
Function handling changed data type commands.
value | Command value |
sessionId | Unique id of the server which is not unique on the client side |
|
protected |
New command function.
command | New command to handle |
value | Command value |
sessionId | Unique id of the server which is not unique on the client side |
|
protected |
Function handling pause commands.
value | Command value |
sessionId | Unique id of the server which is not unique on the client side |
|
protected |
Function handling start commands.
value | Command value |
sessionId | Unique id of the server which is not unique on the client side |
|
protected |
Function handling stop commands.
value | Command value |
sessionId | Unique id of the server which is not unique on the client side |
|
protected |
Callback function for TCP receive message.
data | Received data |
size | Size of the received data, in bytes |
|
protected |
bool Ocean::Network::StreamingClient::pause | ( | ) |
Pauses the streaming.
Channels Ocean::Network::StreamingClient::selectableChannels | ( | ) |
Returns a list of selectable channels provides by the streaming server.
|
inline |
Returns the address of the connected streaming server.
|
inline |
Returns the port of the connected streaming server.
|
inline |
Sets the callback function for streaming data received from the streaming server.
callback | Callback function to set |
|
inline |
Sets the callback function for streaming server requests (like e.g.
start or stop requests).
callback | Callback function to set |
bool Ocean::Network::StreamingClient::start | ( | const std::string & | channel = std::string() | ) |
bool Ocean::Network::StreamingClient::stop | ( | ) |
Stops the streaming.
|
protected |
Stream channel.
|
protected |
Stream data type.
|
protected |
Determines whether the client is pause.
|
protected |
Determines whether the client is currently receiving.
|
protected |
Streaming data receive callback function.
|
protected |
Streaming server request callback function.
|
protected |
Address4 of the streaming server.
|
protected |
TCP client.
|
protected |
UDP client.