OpenTera WebRTC API (C++) 1.2.5
Public Member Functions | Protected Member Functions | List of all members
opentera::DataChannelClient Class Reference

Represents a client for data channel communication. More...

#include <DataChannelClient.h>

Inheritance diagram for opentera::DataChannelClient:
opentera::WebrtcClient

Public Member Functions

 DataChannelClient (SignalingServerConfiguration signalingServerConfiguration, WebrtcConfiguration webrtcConfiguration, DataChannelConfiguration dataChannelConfiguration)
 Creates a data channel client with the specified configurations. More...
 
 DECLARE_NOT_COPYABLE (DataChannelClient)
 
 DECLARE_NOT_MOVABLE (DataChannelClient)
 
bool sendTo (const uint8_t *data, std::size_t size, const std::vector< std::string > &ids)
 
bool sendTo (const std::string &message, const std::vector< std::string > &ids)
 Sends a string message to the specified clients. More...
 
bool sendToAll (const uint8_t *data, std::size_t size)
 
bool sendToAll (const std::string &message)
 Sends a string message to all clients. More...
 
void setOnDataChannelOpened (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a data channel opens. More...
 
void setOnDataChannelClosed (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a data channel closes. More...
 
void setOnDataChannelError (const std::function< void(const Client &, const std::string &)> &callback)
 Sets the callback that is called when a data channel error occurs. More...
 
void setOnDataChannelMessageBinary (const std::function< void(const Client &, const uint8_t *, std::size_t)> &callback)
 Sets the callback that is called when binary data are received. More...
 
void setOnDataChannelMessageString (const std::function< void(const Client &, const std::string &)> &callback)
 Sets the callback that is called when a string message is received. More...
 
- Public Member Functions inherited from opentera::WebrtcClient
 WebrtcClient (SignalingServerConfiguration &&signalingServerConfiguration, WebrtcConfiguration &&webrtcConfiguration, VideoStreamConfiguration &&videoStreamConfiguration)
 
 DECLARE_NOT_COPYABLE (WebrtcClient)
 
 DECLARE_NOT_MOVABLE (WebrtcClient)
 
void setTlsVerificationEnabled (bool isEnabled)
 
void connect ()
 Connects the client the signaling server.
 
void close ()
 Closes all client connections (asynchronous).
 
void closeSync ()
 Closes all client connections (synchronous).
 
void callAll ()
 Calls all room clients.
 
void callIds (const std::vector< std::string > &ids)
 Calls the specified clients. More...
 
void hangUpAll ()
 Hangs up all clients.
 
void closeAllRoomPeerConnections ()
 Closes all room peer connections.
 
bool isConnected ()
 Indicates if the client is connected to the signaling server. More...
 
bool isRtcConnected ()
 Indicates if the client is connected to at least one client (RTCPeerConnection). More...
 
std::string id ()
 Returns the client id. More...
 
std::vector< std::string > getConnectedRoomClientIds ()
 Returns the connected room client ids. More...
 
RoomClient getRoomClient (const std::string &id)
 Returns the room client that matches with the specified id. If no room client matches with the id, a default room client is returned. More...
 
std::vector< RoomClientgetRoomClients ()
 Returns the room clients. More...
 
void setOnSignalingConnectionOpened (const std::function< void()> &callback)
 Sets the callback that is called when the signaling connection opens. More...
 
void setOnSignalingConnectionClosed (const std::function< void()> &callback)
 Sets the callback that is called when the signaling connection closes. More...
 
void setOnSignalingConnectionError (const std::function< void(const std::string &)> &callback)
 Sets the callback that is called when a signaling connection error occurs. More...
 
void setOnRoomClientsChanged (const std::function< void(const std::vector< RoomClient > &)> &callback)
 Sets the callback that is called when the room client changes. More...
 
void setCallAcceptor (const std::function< bool(const Client &)> &callback)
 Sets the callback that is used to accept or reject a call. More...
 
void setOnCallRejected (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a call is rejected. More...
 
void setOnClientConnected (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a client peer connection opens. More...
 
void setOnClientDisconnected (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a client peer connection closes. More...
 
void setOnClientConnectionFailed (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a client peer connection fails. More...
 
void setOnError (const std::function< void(const std::string &error)> &callback)
 Sets the callback that is called when an error occurs. More...
 
void setLogger (const std::function< void(const std::string &message)> &callback)
 Sets the callback that is used to log information. More...
 

Protected Member Functions

bool sendTo (const webrtc::DataBuffer &buffer, const std::vector< std::string > &ids)
 
bool sendToAll (const webrtc::DataBuffer &buffer)
 
std::unique_ptr< PeerConnectionHandlercreatePeerConnectionHandler (const std::string &id, const Client &peerClient, bool isCaller) override
 
- Protected Member Functions inherited from opentera::WebrtcClient
template<class T , class... Types>
void invokeIfCallable (const std::function< T > &f, Types... args)
 
void log (const std::string &message)
 
std::function< void(const std::string &)> getOnErrorFunction ()
 
std::function< void(const Client &)> getOnClientConnectedFunction ()
 
std::function< void(const Client &)> getOnClientDisconnectedFunction ()
 
std::function< void(const Client &)> getOnClientConnectionFailedFunction ()
 
rtc::Thread * getInternalClientThread ()
 

Additional Inherited Members

- Protected Attributes inherited from opentera::WebrtcClient
std::unique_ptr< SignalingClientm_signalingClient
 
rtc::scoped_refptr< webrtc::PeerConnectionFactoryInterface > m_peerConnectionFactory
 
std::map< std::string, std::unique_ptr< PeerConnectionHandler > > m_peerConnectionHandlersById
 
rtc::scoped_refptr< OpenteraAudioDeviceModulem_audioDeviceModule
 
rtc::scoped_refptr< webrtc::AudioProcessing > m_audioProcessing
 

Detailed Description

Represents a client for data channel communication.

Constructor & Destructor Documentation

◆ DataChannelClient()

DataChannelClient::DataChannelClient ( SignalingServerConfiguration  signalingServerConfiguration,
WebrtcConfiguration  webrtcConfiguration,
DataChannelConfiguration  dataChannelConfiguration 
)

Creates a data channel client with the specified configurations.

Parameters
signalingServerConfigurationThe signaling server configuration
webrtcConfigurationThe WebRTC configuration
dataChannelConfigurationThe data channel configuration

Member Function Documentation

◆ sendTo()

bool opentera::DataChannelClient::sendTo ( const std::string &  message,
const std::vector< std::string > &  ids 
)
inline

Sends a string message to the specified clients.

Parameters
messageThe string message
idsThe client ids

◆ sendToAll()

bool opentera::DataChannelClient::sendToAll ( const std::string &  message)
inline

Sends a string message to all clients.

Parameters
messageThe string message

◆ setOnDataChannelClosed()

void opentera::DataChannelClient::setOnDataChannelClosed ( const std::function< void(const Client &)> &  callback)
inline

Sets the callback that is called when a data channel closes.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the data channel that closes
Parameters
callbackThe callback

◆ setOnDataChannelError()

void opentera::DataChannelClient::setOnDataChannelError ( const std::function< void(const Client &, const std::string &)> &  callback)
inline

Sets the callback that is called when a data channel error occurs.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the data channel error
  • error: The error message
Parameters
callbackThe callback

◆ setOnDataChannelMessageBinary()

void opentera::DataChannelClient::setOnDataChannelMessageBinary ( const std::function< void(const Client &, const uint8_t *, std::size_t)> &  callback)
inline

Sets the callback that is called when binary data are received.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client the binary data are from
  • data: The binary data
  • dataSize: The binary data size
Parameters
callbackThe callback

◆ setOnDataChannelMessageString()

void opentera::DataChannelClient::setOnDataChannelMessageString ( const std::function< void(const Client &, const std::string &)> &  callback)
inline

Sets the callback that is called when a string message is received.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client the binary data is from
  • message: The string message
Parameters
callbackThe callback

◆ setOnDataChannelOpened()

void opentera::DataChannelClient::setOnDataChannelOpened ( const std::function< void(const Client &)> &  callback)
inline

Sets the callback that is called when a data channel opens.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the data channel that opens
Parameters
callbackThe callback

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