public static void AddConnection(ConnectionPair pair) { lock (_peersMonitor) { _connectionPairs.Add(pair); } }
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); } }
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; }
private void ProcessConnectionBetweenClients(ConnectionPair connectionPair) { connectionPair.ProcessConnection(); connectionPair.Server.GetClientInfo().Client.ListenMessages(); }
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())); }
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()); }