예제 #1
0
        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;
                    }
                }
            }
        }
예제 #2
0
 /// <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);
 }
예제 #3
0
 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);
 }
예제 #4
0
 /// <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;
 }
예제 #5
0
 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));
 }
예제 #6
0
        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()));
 }
예제 #8
0
        public string SetNetworkConnectionType(string computerName, NetworkConnectionType connectionType)
        {
            var command = "bash set-network-connection-type.sh " + connectionType;

            return(StartCommand(computerName, command));
        }
예제 #9
0
 public NetworkConnectionInfo(
     NetworkConnectionType networkConnectionType, bool limitData)
 {
     NetworkConnectionType = networkConnectionType;
     LimitData             = limitData;
 }
예제 #10
0
 /// <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;
 }
예제 #11
0
        //-------------------------------------------- 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);
        }