DataChannelServer
A C++ library for creating WebRTC DataChannel servers.
Public Member Functions | List of all members
data_channel::DataChannel Class Reference

A class which represents a single peer connection. More...

Public Member Functions

 DataChannel (const DataChannel &other)=delete
 
DataChanneloperator= (const DataChannel &)=delete
 
 ~DataChannel ()
 Closes the channel.
 
void SendMessage (const std::string &message)
 Send a message to the other side. More...
 
void SetOnMessageHandler (std::function< void(const std::string &message)> handler)
 Set a handler for processing new messages. More...
 
void SetOnCloseHandler (std::function< void()> handler)
 Get a notification when the channel is closed. More...
 

Detailed Description

A class which represents a single peer connection.

When this class is destroyed, the connection is closed. You can also set on message and on close handlers. As well as directly send messages.

Member Function Documentation

void data_channel::DataChannel::SendMessage ( const std::string &  message)
inline

Send a message to the other side.

Parameters
messageThe provided message.
void data_channel::DataChannel::SetOnCloseHandler ( std::function< void()>  handler)
inline

Get a notification when the channel is closed.

NOTE: You cannot call SendMessage() after receiving a CloseMessage. You should also free the DataChannel to avoid memory leaks after receiving a close.

Parameters
handlerThe callback for when the channel is closed.
void data_channel::DataChannel::SetOnMessageHandler ( std::function< void(const std::string &message)>  handler)
inline

Set a handler for processing new messages.

Parameters
handlerThe callback when a new message arrives.

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