struct libwebrtc_data_channel* libwebrtc_create_channel( struct libwebrtc_connection* c, const char* name ) { ILibWrapper_WebRTC_Connection connection = (ILibWrapper_WebRTC_Connection)c; if( ! ILibWrapper_WebRTC_Connection_IsConnected( connection ) ) return NULL; ILibWrapper_WebRTC_DataChannel* channel = ILibWrapper_WebRTC_DataChannel_Create(connection, (char*)name, strlen(name), &WebRTCOnDataChannelAck ); // Initially use parent user_data ILibWrapper_WebRTC_Connection_GetUserData(connection, NULL, NULL, &channel->userData); return (libwebrtc_data_channel*)channel; }
// This is called when a WebRTC Connection is established or disconnected void WebRTCConnectionSink(ILibWrapper_WebRTC_Connection connection, int connected) { printf(red"webrtcconnectionsink\n"rst); if(connected) { printf(red"WebRTC connection Established. [%s]\r\n"rst, ILibWrapper_WebRTC_Connection_DoesPeerSupportUnreliableMode(connection)==0?"RELIABLE Only":"UNRELIABLE Supported"); ILibWrapper_WebRTC_DataChannel_Create(connection, "MyDataChannel", 13, &OnDataChannelAck); } else { printf(red"WebRTC connection is closed.\r\n"rst); mConnection = NULL; mDataChannel = NULL; } }
// Creates a WebRTC Data Channel, using the next available Stream ID __declspec(dllexport) ILibWrapper_WebRTC_DataChannel* ILibWrapper_DLL_WebRTC_DataChannel_Create(ILibWrapper_WebRTC_Connection connection, char* channelName, int channelNameLen, ILibWrapper_WebRTC_DataChannel_OnDataChannelAck OnAckHandler, void *userData) { ILibWrapper_WebRTC_DataChannel* retVal = ILibWrapper_WebRTC_DataChannel_Create(connection, channelName, channelNameLen, OnAckHandler); retVal->userData = userData; return(retVal); }