Ejemplo n.º 1
0
        /// <summary>
        /// creates response to request and sends the response
        /// </summary>
        /// <param name="localPeerId">optional local test node ID, is sent by server to new peers who dont know server's PeerId</param>
        internal static void Respond(PeerHelloPacket requestPacket, PeerHelloRequestStatus status, PeerId localPeerId,
                                     SocketWithReceiver socket, IPEndPoint remoteEndPoint, bool thisPeerRoleAsUser = false)
        {
            var responseData = new PeerHelloPacket(requestPacket, status, localPeerId, thisPeerRoleAsUser).Encode();

            socket.UdpSocket.Send(responseData, responseData.Length, remoteEndPoint);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// creates response to request and sends the response
        /// </summary>
        /// <param name="localPeerId">optional local test node ID, is sent by server to new peers who dont know server's PeerId</param>
        internal static void Respond(PeerHelloPacket requestPacket, PeerHelloRequestStatus status, PeerId localPeerId,
                                     SocketWithReceiver socket, IPEndPoint remoteEndPoint, ushort?responseCpuDelayMs = null, bool thisPeerRoleAsUser = false, IpLocationData localIpLocationData = null)
        {
            var responsePacket = new PeerHelloPacket(requestPacket, status, localPeerId, thisPeerRoleAsUser, responseCpuDelayMs, remoteEndPoint.Address.ToString());

            if (localIpLocationData != null && requestPacket.FlagIwantToGetYourIpLocation)
            {
                responsePacket.IpLocationData = localIpLocationData;
            }
            var responseData = responsePacket.Encode();

            socket.UdpSocket.Send(responseData, responseData.Length, remoteEndPoint);
        }