Delegate DelegateOnOpen
Represents the method that will be invoked when the data channel is successfully opened and ready for communication.
Namespace: Unity.WebRTC
Assembly: Unity.WebRTC.dll
Syntax
public delegate void DelegateOnOpen()
Remarks
The DelegateOnOpen
is triggered when the data channel's transport layer becomes successfully established and ready for data transfer.
This indicates that messages can now be sent and received over the channel, marking the transition from connecting to an operational state.
Useful for initializing or signaling to the application that the channel setup is complete and ready for communication.
This delegate is typically assigned to the OnOpen property.
Examples
using UnityEngine;
using Unity.WebRTC;
public class DataChannelOpenExample : MonoBehaviour
{
private void Start()
{
var initOption = new RTCDataChannelInit();
var peerConnection = new RTCPeerConnection();
var dataChannel = peerConnection.CreateDataChannel("test channel", initOption);
// Assign the delegate to handle the OnOpen event
dataChannel.OnOpen = () =>
{
Debug.Log("DataChannel is now open and ready for communication.");
};
}
}