Exemplo n.º 1
0
        /// <summary>
        /// Create a connectionInfo object which can be used to inform a remote peer of local connectivity.
        /// Uses the custom NetworkComms.Net application layer protocol.
        /// </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>
        public ConnectionInfo(ConnectionType connectionType, ShortGuid localNetworkIdentifier, EndPoint localEndPoint, bool isConnectable)
        {
            if (localEndPoint == null)
            {
                throw new ArgumentNullException("localEndPoint", "localEndPoint may not be null");
            }

            this.ConnectionType       = connectionType;
            this.NetworkIdentifierStr = localNetworkIdentifier.ToString();

            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.LocalEndPoint            = localEndPoint;
            this.IsConnectable            = isConnectable;
            this.ApplicationLayerProtocol = ApplicationLayerProtocolStatus.Enabled;
        }
Exemplo n.º 2
0
 /// <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>
 public ConnectionInfo(ConnectionType connectionType, ShortGuid localNetworkIdentifier, IPEndPoint localEndPoint, bool isConnectable)
 {
     this.ConnectionType       = connectionType;
     this.NetworkIdentifierStr = localNetworkIdentifier.ToString();
     this.LocalEndPoint        = localEndPoint;
     this.IsConnectable        = isConnectable;
 }
Exemplo n.º 3
0
 /// <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();
 }