/// <summary> /// Create a connectionInfo object for a new connection. /// </summary> /// <param name="connectionType">The type of connection</param> /// <param name="remoteEndPoint">The remoteEndPoint of this connection</param> /// <param name="localEndPoint">The localEndpoint of this connection</param> /// <param name="applicationLayerProtocol">If enabled NetworkComms.Net uses a custom /// application layer protocol to provide useful features such as inline serialisation, /// transparent packet transmission, remote peer handshake and information etc. We strongly /// recommend you enable the NetworkComms.Net application layer protocol.</param> /// <param name="connectionListener">The listener associated with this connection if server side</param> internal ConnectionInfo(ConnectionType connectionType, EndPoint remoteEndPoint, EndPoint localEndPoint, ApplicationLayerProtocolStatus applicationLayerProtocol = ApplicationLayerProtocolStatus.Enabled, ConnectionListenerBase connectionListener = null) { if (localEndPoint == null) { throw new ArgumentNullException("localEndPoint", "localEndPoint may not be null"); } if (remoteEndPoint == null) { throw new ArgumentNullException("remoteEndPoint", "remoteEndPoint may not be null"); } if (applicationLayerProtocol == ApplicationLayerProtocolStatus.Undefined) { throw new ArgumentException("A value of ApplicationLayerProtocolStatus.Undefined is invalid when creating instance of ConnectionInfo.", "applicationLayerProtocol"); } this.ServerSide = (connectionListener != null); this.ConnectionListener = connectionListener; this.ConnectionType = connectionType; this.RemoteEndPoint = remoteEndPoint; this.LocalEndPoint = localEndPoint; this.ConnectionCreationTime = DateTime.Now; this.ApplicationLayerProtocol = applicationLayerProtocol; }
private void StopP2PListening() { //stop local listening if (_p2pListener != null && _p2pListener.IsListening) { var ipEndPoint = (IPEndPoint)_p2pListener.LocalListenEndPoint; ServerMessageReceivedAction(string.Format("Stop local P2P connection listening on {0}:{1}", ipEndPoint.Address, ipEndPoint.Port)); _p2pListener.RemoveIncomingPacketHandler(); Connection.StopListening(_p2pListener); _p2pListener = null; } }