/// <summary>
        /// Send a message through the data channel. If the message cannot be sent, for example because of congestion
        /// control, it is buffered internally. If this buffer gets full, an exception is thrown and this call is aborted.
        /// The internal buffering is monitored via the <see cref="BufferingChanged"/> event.
        /// </summary>
        /// <param name="message">The message to send to the remote peer.</param>
        /// <exception xref="InvalidOperationException">The native data channel is not initialized.</exception>
        /// <exception xref="Exception">The internal buffer is full.</exception>
        /// <seealso cref="PeerConnection.InitializeAsync"/>
        /// <seealso cref="PeerConnection.Initialized"/>
        /// <seealso cref="BufferingChanged"/>
        public void SendMessage(byte[] message)
        {
            MainEventSource.Log.DataChannelSendMessage(ID, message.Length);
            uint res = DataChannelInterop.DataChannel_SendMessage(_interopHandle, message, (ulong)message.LongLength);

            Utils.ThrowOnErrorCode(res);
        }
Example #2
0
        /// <summary>
        /// Send a message through the data channel. If the message cannot be sent, for example because of congestion
        /// control, it is buffered internally. If this buffer gets full, an exception is thrown and this call is aborted.
        /// The internal buffering is monitored via the <see cref="BufferingChanged"/> event.
        /// </summary>
        /// <param name="message">The message to send to the remote peer.</param>
        /// <param name="size">The size of the message to send in octects.</param>
        /// <exception xref="InvalidOperationException">The native data channel is not initialized.</exception>
        /// <exception xref="Exception">The internal buffer is full.</exception>
        /// <seealso cref="PeerConnection.InitializeAsync"/>
        /// <seealso cref="BufferingChanged"/>
        public void SendMessage(IntPtr message, ulong size)
        {
            MainEventSource.Log.DataChannelSendMessage(ID, (int)size);
            uint res = DataChannelInterop.DataChannel_SendMessage(_nativeHandle, message, size);

            Utils.ThrowOnErrorCode(res);
        }
Example #3
0
        /// <summary>
        /// Send a message through the data channel. If the message cannot be sent, for example because of congestion
        /// control, it is buffered internally. If this buffer gets full, an exception is thrown and this call is aborted.
        /// The internal buffering is monitored via the <see cref="BufferingChanged"/> event.
        /// </summary>
        /// <param name="message">The message to send to the remote peer.</param>
        /// <exception xref="System.InvalidOperationException">The native data channel is not initialized.</exception>
        /// <exception xref="System.Exception">The internal buffer is full.</exception>
        /// <exception cref="DataChannelNotOpenException">The data channel is not open yet.</exception>
        /// <seealso cref="PeerConnection.InitializeAsync"/>
        /// <seealso cref="BufferingChanged"/>
        public void SendMessage(byte[] message)
        {
            MainEventSource.Log.DataChannelSendMessage(ID, message.Length);
            // Check channel state before doing a P/Invoke call which would anyway fail
            if (State != ChannelState.Open)
            {
                throw new DataChannelNotOpenException();
            }
            uint res = DataChannelInterop.DataChannel_SendMessage(_nativeHandle, message, (ulong)message.LongLength);

            Utils.ThrowOnErrorCode(res);
        }
Example #4
0
 /// <summary>
 /// Send a message through the data channel.
 /// </summary>
 /// <param name="message">The message to send to the remote peer.</param>
 /// <exception xref="InvalidOperationException">The peer connection is not initialized.</exception>
 /// <seealso cref="PeerConnection.InitializeAsync"/>
 /// <seealso cref="PeerConnection.Initialized"/>
 public void SendMessage(byte[] message)
 {
     DataChannelInterop.DataChannel_SendMessage(_interopHandle, message, (ulong)message.LongLength);
 }