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);
        }
 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);
        }
        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();
 }
 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());
 }