/// <summary> /// Tries the add end point. /// /// </summary> /// <param name="endPoint">The end point.</param> /// <returns><see langword="true"/> if the endpoint has been added, <see langword="false"/> if the endpoint was already listed.</returns> public bool TryAddEndPoint(IPEndPoint endPoint) { endPoint = endPoint.EnsureIPv6(); if (connectionsToAttempt.Exists(ip => ip.Equals(endPoint))) { logger.LogDebug("EndPoint {RemoteEndPoint} already in the list of connections attempt.", endPoint); return(false); } else { connectionsToAttempt.Add(new OutgoingConnectionEndPoint(endPoint)); logger.LogDebug("EndPoint {RemoteEndPoint} added to the list of connections attempt.", endPoint); return(true); } }
public ServerPeer(ILogger <ServerPeer> logger, IEventBus eventBus, IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, IEnumerable <IServerPeerConnectionGuard> serverPeerConnectionGuards, IPeerConnectionFactory peerConnectionFactory) { this.logger = logger; this.eventBus = eventBus; this.serverPeerConnectionGuards = serverPeerConnectionGuards; this.peerConnectionFactory = peerConnectionFactory; this.LocalEndPoint = localEndPoint.EnsureIPv6(); this.RemoteEndPoint = remoteEndPoint.EnsureIPv6(); this.connectedPeers = new Dictionary <string, IPeerConnection>(); this.listenerCancellation = new CancellationTokenSource(); this.tcpListener = new ForgeTcpListener(this.LocalEndPoint); this.onPeerDisconnectedSubscription = this.eventBus.Subscribe <PeerDisconnected>(this.OnPeerDisconnected); }
public OutgoingConnectionEndPoint(IPEndPoint endPoint) { EndPoint = endPoint.EnsureIPv6(); }