Ejemplo n.º 1
0
        public void Close()
        {
            if (!IsRunning)
                return;

            IsRunning = false;

            var closeConnectionMessage = new RequestMessage(MessageType.CloseConnection);
            _superPeerClient.Send(closeConnectionMessage);

            try
            {
                Thread.Sleep(5000);
                _superPeerClient.Close();
            }
            catch (SocketException)
            {
            }
        }
Ejemplo n.º 2
0
        private PeerAddress GetPeerAddress()
        {
            var requestMessage = new RequestMessage(MessageType.ClientPeerAddress);
            _superPeerClient.Send(requestMessage);

            PeerAddress peerAddress = ((PeerAddressMessage)_superPeerClient.Read()).PeerAddress;
            peerAddress.PrivateEndPoint = new IPEndPoint(LocalIpAddress(), _superPeerClient.LocalEndPoint.Port);
            _superPeerClient.Send(new PeerAddressMessage(peerAddress, MessageType.ClientPeerAddress));

            return peerAddress;
        }