/// <summary> /// Create a connectionInfo object which can be used to inform a remote peer of local connectivity /// </summary> /// <param name="connectionType">The type of connection</param> /// <param name="localNetworkIdentifier">The local network identifier</param> /// <param name="localEndPoint">The localEndPoint which should be referenced remotely</param> /// <param name="isConnectable">True if connectable on provided localEndPoint</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> public ConnectionInfo(ConnectionType connectionType, ShortGuid localNetworkIdentifier, EndPoint localEndPoint, bool isConnectable, ApplicationLayerProtocolStatus applicationLayerProtocol) { if (localEndPoint == null) { throw new ArgumentNullException("localEndPoint", "localEndPoint 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.ConnectionType = connectionType; this.NetworkIdentifierStr = localNetworkIdentifier.ToString(); this.LocalEndPoint = localEndPoint; switch (localEndPoint.AddressFamily) { case AddressFamily.InterNetwork: this.RemoteEndPoint = new IPEndPoint(IPAddress.Any, 0); break; case AddressFamily.InterNetworkV6: this.RemoteEndPoint = new IPEndPoint(IPAddress.IPv6Any, 0); break; #if NET4 || NET35 case (AddressFamily)32: this.RemoteEndPoint = new BluetoothEndPoint(BluetoothAddress.None, BluetoothService.SerialPort); break; #endif } this.IsConnectable = isConnectable; this.ApplicationLayerProtocol = applicationLayerProtocol; }
/// <summary> /// Replaces the current networkIdentifier with that provided /// </summary> /// <param name="networkIdentifier">The new networkIdentifier for this connectionInfo</param> public void ResetNetworkIdentifer(ShortGuid networkIdentifier) { NetworkIdentifierStr = networkIdentifier.ToString(); }