Intel® Collaboration Suite for WebRTC  version 4.3.1
Open WebRTC Toolkit (OWT) Client SDK for Windows*
owt::p2p::P2PClient Class Referencefinal

An async client for P2P WebRTC sessions. More...

#include <owt/p2p/p2pclient.h>

Inheritance diagram for owt::p2p::P2PClient:
Collaboration diagram for owt::p2p::P2PClient:

Public Member Functions

 P2PClient (P2PClientConfiguration &configuration, std::shared_ptr< P2PSignalingChannelInterface > signaling_channel)
 Init a P2PClient instance with speficied signaling channel. More...
 
void AddObserver (P2PClientObserver &observer)
 
void RemoveObserver (P2PClientObserver &observer)
 
void Connect (const std::string &host, const std::string &token, std::function< void(const std::string &)> on_success, std::function< void(std::unique_ptr< Exception >)> on_failure)
 Connect to the signaling server. More...
 
void Disconnect (std::function< void()> on_success, std::function< void(std::unique_ptr< Exception >)> on_failure)
 Disconnect from the signaling server. It will stop all active WebRTC sessions. More...
 
void AddAllowedRemoteId (const std::string &target_id)
 Add a remote user to the allowed list to start a WebRTC session. More...
 
void RemoveAllowedRemoteId (const std::string &target_id, std::function< void()> on_success, std::function< void(std::unique_ptr< Exception >)> on_failure)
 Remove a remote user from the allowed list to stop a WebRTC session. More...
 
void Stop (const std::string &target_id, std::function< void()> on_success, std::function< void(std::unique_ptr< Exception >)> on_failure)
 Stop a WebRTC session. More...
 
void Publish (const std::string &target_id, std::shared_ptr< owt::base::LocalStream > stream, std::function< void(std::shared_ptr< P2PPublication >)> on_success, std::function< void(std::unique_ptr< Exception >)> on_failure)
 Publish a stream to the remote client. More...
 
void Send (const std::string &target_id, const std::string &message, std::function< void()> on_success, std::function< void(std::unique_ptr< Exception >)> on_failure)
 Send a message to remote client. More...
 
void GetConnectionStats (const std::string &target_id, std::function< void(std::shared_ptr< owt::base::ConnectionStats >)> on_success, std::function< void(std::unique_ptr< Exception >)> on_failure)
 Get the connection statistowt with target client. More...
 

Detailed Description

An async client for P2P WebRTC sessions.

Constructor & Destructor Documentation

◆ P2PClient()

owt::p2p::P2PClient::P2PClient ( P2PClientConfiguration configuration,
std::shared_ptr< P2PSignalingChannelInterface signaling_channel 
)

Init a P2PClient instance with speficied signaling channel.

Parameters
configurationConfiguration for creating the P2PClient.
signaling_channelSignaling channel used for exchange signaling messages.

Member Function Documentation

◆ AddAllowedRemoteId()

void owt::p2p::P2PClient::AddAllowedRemoteId ( const std::string &  target_id)

Add a remote user to the allowed list to start a WebRTC session.

Parameters
target_idRemote user's ID.

◆ AddObserver()

void owt::p2p::P2PClient::AddObserver ( P2PClientObserver observer)

Add an observer for peer client.

Parameters
observerAdd this object to observer list. Do not delete this object until it is removed from observer list.

◆ Connect()

void owt::p2p::P2PClient::Connect ( const std::string &  host,
const std::string &  token,
std::function< void(const std::string &)>  on_success,
std::function< void(std::unique_ptr< Exception >)>  on_failure 
)

Connect to the signaling server.

Parameters
hostThe URL of signaling server to connect
tokenA token used for connection and authentication
on_successSucess callback will be invoked with current user's ID if connect to server successfully.
on_failureFailure callback will be invoked if one of these cases happened:
  1. P2PClient is connecting or connected to a server.
  2. Invalid token.

◆ Disconnect()

void owt::p2p::P2PClient::Disconnect ( std::function< void()>  on_success,
std::function< void(std::unique_ptr< Exception >)>  on_failure 
)

Disconnect from the signaling server. It will stop all active WebRTC sessions.

Parameters
on_successSucess callback will be invoked if disconnect from server successfully.
on_failureFailure callback will be invoked if one of these cases happened:
  1. P2PClient hasn't connected to a signaling server.

◆ GetConnectionStats()

void owt::p2p::P2PClient::GetConnectionStats ( const std::string &  target_id,
std::function< void(std::shared_ptr< owt::base::ConnectionStats >)>  on_success,
std::function< void(std::unique_ptr< Exception >)>  on_failure 
)

Get the connection statistowt with target client.

Parameters
target_idRemote user's ID.
on_successSuccess callback will be invoked if get statistoms information successes.
on_failureFailure callback will be invoked if one of the following cases happened.
  1. P2PClient is disconnected from the server.
  2. Target ID is invalid.
  3. There is no WebRTC session with target user.

◆ Publish()

void owt::p2p::P2PClient::Publish ( const std::string &  target_id,
std::shared_ptr< owt::base::LocalStream stream,
std::function< void(std::shared_ptr< P2PPublication >)>  on_success,
std::function< void(std::unique_ptr< Exception >)>  on_failure 
)

Publish a stream to the remote client.

Parameters
streamThe stream which will be published.
target_idTarget user's ID.
on_successSuccess callback will be invoked it the stream is published.
on_failureFailure callback will be invoked if one of these cases happened:
  1. P2PClient is disconnected from server.
  2. Target ID is null or user is offline.
  3. Haven't connected to remote client.

◆ RemoveAllowedRemoteId()

void owt::p2p::P2PClient::RemoveAllowedRemoteId ( const std::string &  target_id,
std::function< void()>  on_success,
std::function< void(std::unique_ptr< Exception >)>  on_failure 
)

Remove a remote user from the allowed list to stop a WebRTC session.

Parameters
target_idRemote user's ID.
on_successSuccess callback will be invoked if removing a remote user successfully.
on_failureFailure callback will be invoked if one of the following cases happened.
  1. P2PClient is disconnected from the server.
  2. Target ID is null or target user is offline.

◆ RemoveObserver()

void owt::p2p::P2PClient::RemoveObserver ( P2PClientObserver observer)

Remove an observer from peer client.

Parameters
observerRemove this object from observer list.

◆ Send()

void owt::p2p::P2PClient::Send ( const std::string &  target_id,
const std::string &  message,
std::function< void()>  on_success,
std::function< void(std::unique_ptr< Exception >)>  on_failure 
)

Send a message to remote client.

Parameters
target_idRemote user's ID.
messageThe message to be sent.
on_successSuccess callback will be invoked if message sent successfully.
on_failureFailure callback will be invoked if one of the following cases happened.
  1. P2PClient is disconnected from the server.
  2. Target ID is null or target user is offline.
  3. There is no WebRTC session with target user.

◆ Stop()

void owt::p2p::P2PClient::Stop ( const std::string &  target_id,
std::function< void()>  on_success,
std::function< void(std::unique_ptr< Exception >)>  on_failure 
)

Stop a WebRTC session.

Parameters
target_idRemote user's ID.
target_idSuccess callback will be invoked if send stop event successfully.
on_failureFailure callback will be invoked if one of the following cases happened.
  1. P2PClient is disconnected from the server.
  2. Target ID is null or target user is offline.
  3. There is no WebRTC session with target user.