private void OnNetworkConnectionChanged(NetworkConnectionType newConnection) { var connectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (connectionProfile == null) { this.IsActive = newConnection == NetworkConnectionType.Disconnected; } else { var connectionState = connectionProfile.GetNetworkConnectivityLevel(); if (connectionState != NetworkConnectivityLevel.InternetAccess) { this.IsActive = newConnection == NetworkConnectionType.Disconnected; } else { if (connectionProfile.NetworkAdapter.IanaInterfaceType.Equals(6)) { this.IsActive = newConnection == NetworkConnectionType.Ethernet; } else if (connectionProfile.IsWlanConnectionProfile) { this.IsActive = newConnection == NetworkConnectionType.WiFi; } else if (connectionProfile.IsWwanConnectionProfile) { this.IsActive = newConnection == NetworkConnectionType.Mobile; } } } }
/// <summary> /// Initializes a new instance of the <see cref="NetworkStatusChangedEventArgs"/> class. /// </summary> /// <param name="profileName"> /// The network profile name. /// </param> /// <param name="connectionType"> /// The connection type. /// </param> /// <param name="mobileSignalState"> /// The mobile connection type. /// </param> /// <param name="signal"> /// The signal strength. /// </param> public NetworkStatusChangedEventArgs( string profileName, NetworkConnectionType connectionType, MobileNetworkConnectionType mobileSignalState, byte?signal) { this.Status = new NetworkStatus(profileName, connectionType, mobileSignalState, signal); }
public static NetworkConnectionType GetConnectionType() { #if WINDOWS_PHONE if (NetworkConnectionTypeName == null) // always checking connection type on Android, because the process may still be alive #endif lastType = GetConnectionTypeEx(); return(lastType); }
/// <summary> /// Initializes a new instance of the <see cref="NetworkStatus"/> class. /// </summary> /// <param name="profileName"> /// The network profile name. /// </param> /// <param name="connectionType"> /// The connection type. /// </param> /// <param name="mobileConnectionType"> /// The mobile connection type. /// </param> /// <param name="signal"> /// The signal strength. /// </param> public NetworkStatus( string profileName, NetworkConnectionType connectionType, MobileNetworkConnectionType mobileConnectionType, byte?signal) { this.ProfileName = profileName; this.ConnectionType = connectionType; this.MobileConnectionType = mobileConnectionType; this.Signal = signal; }
public PROTO_NC_MISC_S2SCONNECTION_REQ(NetworkConnectionType from, NetworkConnectionType to, byte worldNo, string worldName, byte zoneNo, string ip, ushort port) : base(NetworkCommand.NC_MISC_S2SCONNECTION_REQ) { Write((byte)from); Write((byte)to); Write(worldNo); Write(worldName, 20); Write(zoneNo); Write(ip, 16); Write(port); Write((ushort)((byte)from + (byte)to)); }
public void Initialize_should_set_network_protocol(string protocolStr, NetworkConnectionType connectionType) { var args = new Dictionary <string, string> { { RuntimeConfigNames.LinkProtocol, protocolStr } }; var connParams = new ConnectionParameters(); new CommandLineConnectionParameterInitializer(args).Initialize(connParams); Assert.AreEqual(connectionType, connParams.Network.ConnectionType); }
/// <summary> /// Method to translate <see cref="NetworkConnectionType"/>. /// </summary> /// <param name="networkConnectionType"><see cref="NetworkConnectionType"/>.</param> /// <returns>Translated <see cref="NetworkConnectionType"/>.</returns> public string Translate(NetworkConnectionType networkConnectionType) { return(Translate(networkConnectionType.ToString())); }
public string SetNetworkConnectionType(string computerName, NetworkConnectionType connectionType) { var command = "bash set-network-connection-type.sh " + connectionType; return(StartCommand(computerName, command)); }
public NetworkConnectionInfo( NetworkConnectionType networkConnectionType, bool limitData) { NetworkConnectionType = networkConnectionType; LimitData = limitData; }
/// <summary> /// Creates a new instance of the <see cref="NetworkServer"/> class. /// </summary> public NetworkServer(NetworkConnectionType connectionType) { Connections = new List <NetworkConnection>(); _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this._connectionType = connectionType; }
//-------------------------------------------- Connection Functions ------------------------------------------------------------------- /// <summary> /// Connect to MMU /// </summary> /// <param name="mmuIpAddress"></param> /// <param name="mmuPort"></param> /// <param name="connectionType"></param> /// <returns></returns> public FunctionResult Connect( string mmuIpAddress = DEFAULT_MMU_IP_ADDRESS, int mmuPort = DEFAULT_MMU_PORT, NetworkConnectionType connectionType = DEFAULT_NETWORK_CONNECTION_TYPE) { MMUIpAddress = mmuIpAddress; MMUPort = mmuPort; MMUConnectionType = connectionType; if (MMUConnectStatus == ConnectStatus.DisConnected) { switch (MMUConnectionType) { case NetworkConnectionType.TCP: if (BasicTcpClientOperation.TcpConnectClientToServer(MMUIpAddress, MMUPort) == FunctionResult.Success) { } else { return(FunctionResult.Fail); } break; case NetworkConnectionType.UDP: if (BasicUdpClientOperation.UdpConnectLocalToRemote(MMUIpAddress, MMUPort) == FunctionResult.Success) { } else { return(FunctionResult.Fail); } break; default: return(FunctionResult.Fail); } // Note : MMUConnectStatus change must before create FFTAICommunicationReceiveListenerThread !!! MMUConnectStatus = ConnectStatus.Connected; // build children thread to handler data receive listening if (FFTAICommunicationReceiveListenerThread == null) { } else { FFTAICommunicationReceiveListenerThread = null; } FFTAICommunicationReceiveListenerThread = new Thread(ReceiveMessageListener); FFTAICommunicationReceiveListenerThreadActiveFlag = false; FFTAICommunicationReceiveListenerThread.Start(); // sleep to let main thread give time to create children thread. while (FFTAICommunicationReceiveListenerThreadActiveFlag == false) { Thread.Sleep(10); } // log information FFTAICommunicationManager.Instance.Logger.WriteLine("FFTAICommunication 创建网络连接和监听子线程成功.", true); } else { ObserverNotifyConnect(); return(FunctionResult.NetworkAlreadyConnected); } ObserverNotifyConnect(); return(FunctionResult.Success); }