コード例 #1
0
 public static void AddConnection(ConnectionPair pair)
 {
     lock (_peersMonitor)
     {
         _connectionPairs.Add(pair);
     }
 }
コード例 #2
0
        private void InitConnectionAsClient(PeerAddress peerAddress)
        {
            List <SuperPeerServer> onlineServers = new List <SuperPeerServer>(ConnectionsRepository.GetServers());
            SuperPeerServer        targetServer  = null;

            foreach (SuperPeerServer server in onlineServers)
            {
                if (server.GetClientInfo().PeerAddress().Equals(peerAddress))
                {
                    targetServer = server;
                }
            }

            if (targetServer == null)
            {
                return;
            }

            if (!targetServer.AllowedConnection.Equals(_superPeerClient.GetClientInfo().PeerAddress()))
            {
                return;
            }

            ConnectionPair connectionPair = CreateConnectionPair(targetServer, _superPeerClient);

            ProcessConnectionBetweenClients(connectionPair);
        }
コード例 #3
0
 public static void RemoveConnection(ConnectionPair pair)
 {
     lock (_peersMonitor)
     {
         _connectionPairs.Remove(pair);
     }
 }
コード例 #4
0
 public static void AddConnection(ConnectionPair pair)
 {
     lock (_peersMonitor)
     {
         _connectionPairs.Add(pair);
     }
 }
コード例 #5
0
 public static void RemoveConnection(ConnectionPair pair)
 {
     lock (_peersMonitor)
     {
         _connectionPairs.Remove(pair);
     }
 }
コード例 #6
0
        private ConnectionPair CreateConnectionPair(SuperPeerServer server, SuperPeerClient client)
        {
            ConnectionPair connectionPair = new ConnectionPair(server, client);

            if (!ConnectionsRepository.GetConnections().Contains(connectionPair))
            {
                ConnectionsRepository.AddConnection(connectionPair);
                return(connectionPair);
            }

            return(null);
        }
コード例 #7
0
        private ConnectionPair CreateConnectionPair(SuperPeerServer server, SuperPeerClient client)
        {
            ConnectionPair connectionPair = new ConnectionPair(server, client);

            if (!ConnectionsRepository.GetConnections().Contains(connectionPair))
            {
                ConnectionsRepository.AddConnection(connectionPair);
                return connectionPair;
            }

            return null;
        }
コード例 #8
0
 private void ProcessConnectionBetweenClients(ConnectionPair connectionPair)
 {
     connectionPair.ProcessConnection();
     connectionPair.Server.GetClientInfo().Client.ListenMessages();
 }
コード例 #9
0
 private void ProcessConnectionBetweenClients(ConnectionPair connectionPair)
 {
     connectionPair.ProcessConnection();
     connectionPair.Server.GetClientInfo().Client.ListenMessages();
 }
コード例 #10
0
 protected bool Equals(ConnectionPair other)
 {
     return(Equals(Client.GetSuperPeerClient().LocalEndPoint.ToString(), other.Client.GetSuperPeerClient().LocalEndPoint.ToString()) &&
            Equals(Server.GetSuperPeerClient().LocalEndPoint.ToString(), other.Server.GetSuperPeerClient().LocalEndPoint.ToString()));
 }
コード例 #11
0
 protected bool Equals(ConnectionPair other)
 {
     return Equals(Client.GetSuperPeerClient().LocalEndPoint.ToString(), other.Client.GetSuperPeerClient().LocalEndPoint.ToString())
            && Equals(Server.GetSuperPeerClient().LocalEndPoint.ToString(), other.Server.GetSuperPeerClient().LocalEndPoint.ToString());
 }