Ocean
Ocean::Network::StreamingClient Class Reference

This class implements a streaming client. More...

Inheritance diagram for Ocean::Network::StreamingClient:

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 Address4serverAddress () const
 Returns the address of the connected streaming server. More...
 
const PortserverPort () 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...
 
Streamingoperator= (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...
 

Detailed Description

This class implements a streaming client.


The client uses a TCP connection for configuration tasks and a UDP connection for the data transfer.

Member Typedef Documentation

◆ Channels

typedef std::vector<std::string> Ocean::Network::StreamingClient::Channels

Definition of a vector holding channels.

◆ ReceiveCallback

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

◆ RequestCallback

typedef Callback<bool, const State, const std::string&> Ocean::Network::StreamingClient::RequestCallback

Definition of a callback function for streaming server requests.

Constructor & Destructor Documentation

◆ StreamingClient()

Ocean::Network::StreamingClient::StreamingClient ( )

Creates a new streaming client.

◆ ~StreamingClient()

Ocean::Network::StreamingClient::~StreamingClient ( )

Destructs a streaming client.

Member Function Documentation

◆ channel()

const std::string & Ocean::Network::StreamingClient::channel ( ) const
inline

Returns the selected channel of the streaming server.

Returns
Selected channel

◆ channelDataType()

std::string Ocean::Network::StreamingClient::channelDataType ( const std::string &  channel)

Returns a data type of a specified channel provides by the streaming server.

Parameters
channelChannel to return the data type for
Returns
Data type

◆ connect()

bool Ocean::Network::StreamingClient::connect ( const Address4 address,
const Port port 
)

Connects the streaming client with a remote streaming server.

Parameters
addressAddress4 of the streaming server
portPort of the streaming server
Returns
True, if succeeded

◆ dataType()

const std::string & Ocean::Network::StreamingClient::dataType ( ) const
inline

Returns the type of the streaming data.

Returns
Data type

◆ disconnect()

bool Ocean::Network::StreamingClient::disconnect ( )

Disconnects the streaming client.

Returns
True, if the client was connected before

◆ isConnected()

bool Ocean::Network::StreamingClient::isConnected ( ) const

Returns whether this client is currently connected with a streaming server.

Returns
True, if so

◆ isPaused()

bool Ocean::Network::StreamingClient::isPaused ( )
inline

Returns whether this client is currently paused.

Returns
True, if so

◆ isReceiving()

bool Ocean::Network::StreamingClient::isReceiving ( )
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.

Returns
True, if so

◆ onChangedDataType()

void Ocean::Network::StreamingClient::onChangedDataType ( const std::string &  value,
const SessionId  sessionId 
)
protected

Function handling changed data type commands.

Parameters
valueCommand value
sessionIdUnique id of the server which is not unique on the client side

◆ onCommand()

void Ocean::Network::StreamingClient::onCommand ( const std::string &  command,
const std::string &  value,
const SessionId  sessionId 
)
protected

New command function.

Parameters
commandNew command to handle
valueCommand value
sessionIdUnique id of the server which is not unique on the client side

◆ onPause()

void Ocean::Network::StreamingClient::onPause ( const std::string &  value,
const SessionId  sessionId 
)
protected

Function handling pause commands.

Parameters
valueCommand value
sessionIdUnique id of the server which is not unique on the client side

◆ onStart()

void Ocean::Network::StreamingClient::onStart ( const std::string &  value,
const SessionId  sessionId 
)
protected

Function handling start commands.

Parameters
valueCommand value
sessionIdUnique id of the server which is not unique on the client side

◆ onStop()

void Ocean::Network::StreamingClient::onStop ( const std::string &  value,
const SessionId  sessionId 
)
protected

Function handling stop commands.

Parameters
valueCommand value
sessionIdUnique id of the server which is not unique on the client side

◆ onTCPReceiveData()

void Ocean::Network::StreamingClient::onTCPReceiveData ( const void *  data,
const size_t  size 
)
protected

Callback function for TCP receive message.

Parameters
dataReceived data
sizeSize of the received data, in bytes

◆ onUDPReceiveData()

void Ocean::Network::StreamingClient::onUDPReceiveData ( const Address4 address,
const Port port,
const void *  data,
const size_t  size,
const PackagedSocket::MessageId  messageId 
)
protected

Callback function for UDP receive message.

Parameters
addressAddress4 of the sender
portPort of the sender
dataReceived data
sizeSize of the received data
messageIdUnique message id for the received message

◆ pause()

bool Ocean::Network::StreamingClient::pause ( )

Pauses the streaming.

Returns
True, if succeeded

◆ selectableChannels()

Channels Ocean::Network::StreamingClient::selectableChannels ( )

Returns a list of selectable channels provides by the streaming server.

Returns
Selectable channels

◆ serverAddress()

const Address4 & Ocean::Network::StreamingClient::serverAddress ( ) const
inline

Returns the address of the connected streaming server.

Returns
Streaming server address

◆ serverPort()

const Port & Ocean::Network::StreamingClient::serverPort ( ) const
inline

Returns the port of the connected streaming server.

Returns
Streaming server port

◆ setReceiveCallback()

void Ocean::Network::StreamingClient::setReceiveCallback ( const ReceiveCallback callback)
inline

Sets the callback function for streaming data received from the streaming server.

Parameters
callbackCallback function to set

◆ setRequestCallback()

void Ocean::Network::StreamingClient::setRequestCallback ( const RequestCallback callback)
inline

Sets the callback function for streaming server requests (like e.g.

start or stop requests).

Parameters
callbackCallback function to set

◆ start()

bool Ocean::Network::StreamingClient::start ( const std::string &  channel = std::string())

(Re-)Starts the streaming.

Parameters
channelStreaming channel, if any
Returns
True, if succeeded

◆ stop()

bool Ocean::Network::StreamingClient::stop ( )

Stops the streaming.

Returns
True, if succeeded

Field Documentation

◆ channel_

std::string Ocean::Network::StreamingClient::channel_
protected

Stream channel.

◆ dataType_

std::string Ocean::Network::StreamingClient::dataType_
protected

Stream data type.

◆ isPaused_

bool Ocean::Network::StreamingClient::isPaused_ = false
protected

Determines whether the client is pause.

◆ isReceiving_

bool Ocean::Network::StreamingClient::isReceiving_ = false
protected

Determines whether the client is currently receiving.

◆ lock_

Lock Ocean::Network::StreamingClient::lock_
mutableprotected

Client lock.

◆ receiveCallback_

ReceiveCallback Ocean::Network::StreamingClient::receiveCallback_
protected

Streaming data receive callback function.

◆ requestCallback_

RequestCallback Ocean::Network::StreamingClient::requestCallback_
protected

Streaming server request callback function.

◆ serverAddress_

Address4 Ocean::Network::StreamingClient::serverAddress_
protected

Address4 of the streaming server.

◆ serverPort_

Port Ocean::Network::StreamingClient::serverPort_
protected

Port of the streaming server.

◆ tcpClient_

TCPClient Ocean::Network::StreamingClient::tcpClient_
protected

TCP client.

◆ udpClient_

PackagedUDPServer Ocean::Network::StreamingClient::udpClient_
protected

UDP client.


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