コード例 #1
0
        /// <summary>
        /// Handler for receiving packets from a Peer on a dummy TURN relay socket. The packets arrive from a peer
        /// and need to be forwarded to the client in a STUN Data Indication message.
        /// </summary>
        /// <param name="receiver">The receiver the packet was received on.</param>
        /// <param name="localPort">The port number the packet was received on.</param>
        /// <param name="remoteEndPoint">The end point of the peer sending traffic to the TURN server.</param>
        /// <param name="packet">The byes received from the peer.</param>
        private void OnRelayPacketReceived(UdpReceiver receiver, int localPort, IPEndPoint remoteEndPoint, byte[] packet)
        {
            STUNMessage dataInd = new STUNMessage(STUNMessageTypesEnum.DataIndication);

            dataInd.Attributes.Add(new STUNAttribute(STUNAttributeTypesEnum.Data, packet));
            dataInd.AddXORPeerAddressAttribute(remoteEndPoint.Address, remoteEndPoint.Port);

            _clientSocket.SendTo(dataInd.ToByteBuffer(null, false), _clientEndPoint);
        }