private void RaiseNetworkChanged()
 {
     if (NetworkChanged != null)
     {
         NetworkChanged.Invoke(this, null);
     }
 }
예제 #2
0
        //----------------------------------------


        #region Public Methods

        #endregion


        //----------------------------------------


        #region Protected Methods
        protected void OnNetworkChanged()
        {
            if (NetworkChanged != null)
            {
                NetworkChanged.Invoke(this, EventArgs.Empty);
            }
        }
예제 #3
0
        public async Task DisconectAsync()
        {
            await m_client.LogoutAsync();

            await m_client.StopAsync();

            NetworkStatus = OnlineStatus.Offline;
            NetworkChanged?.Invoke(this, new NetworkChangedEventArgs(NetworkStatus));
        }
예제 #4
0
        private void OnNetworkChanged()
        {
            lock (_localIpAddressSyncLock)
            {
                _localIpAddresses = null;
                _macAddresses     = null;
            }

            NetworkChanged?.Invoke(this, EventArgs.Empty);
        }
예제 #5
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnNetworkChanged
 ///
 /// <summary>
 /// NetworkChanged イベントを発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnNetworkChanged(NetworkAvailabilityEventArgs e)
 {
     if (Network.Available && State == TimerState.Suspend)
     {
         Resume(TimeSpan.FromMilliseconds(100));
     }
     else if (!Network.Available && State == TimerState.Run)
     {
         Suspend();
     }
     NetworkChanged?.Invoke(this, e);
 }
예제 #6
0
        public async Task ConnectAsync()
        {
            if (!Initialized)
            {
                await InitializeAsync();
            }

            await m_client.LoginAsync(TokenType.Bot, Keys.UserToken);

            NetworkStatus = OnlineStatus.Online;
            ConnectedTime = DateTime.UtcNow;
            NetworkChanged?.Invoke(this, new NetworkChangedEventArgs(NetworkStatus));

            await m_client.StartAsync();
        }
        /// <summary>
        /// Checks the current connection information and raises <see cref="NetworkChanged"/> if needed.
        /// </summary>
        private void UpdateConnectionInformation()
        {
            lock (ConnectionInformation)
            {
                try
                {
                    ConnectionInformation.UpdateConnectionInformation(NetworkInformation.GetInternetConnectionProfile());

                    NetworkChanged?.Invoke(this, EventArgs.Empty);
                }
                catch
                {
                    ConnectionInformation.Reset();
                }
            }
        }
예제 #8
0
        private void OnNetworkStatusChanged(object sender)
        {
            ConnectionProfile profile = null;

            try
            {
                profile = NetworkInformation.GetInternetConnectionProfile();
            }
            catch
            {
            }

            ConnectionInformation.UpdateConnectionInformation(profile);

            NetworkChanged?.Invoke(this, EventArgs.Empty);
        }
예제 #9
0
        public API()
        {
            HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
            filter.AutomaticDecompression = true;
            HttpClient http = new HttpClient(filter);
            cookieMonster = filter.CookieManager;

            client = http;
            loggedIn = false;
            gotInternet = false;

            //debug = true;

            network = new NetworkChanged();

            Windows.Networking.Connectivity.NetworkInformation.NetworkStatusChanged += NetworkStatusChanged;
        }
예제 #10
0
        public API(HttpClient http, string lastVis)
        {
            if (http == null)
            {
                throw new Exception("No client is provided");
            }

            lastPage    = lastVis;
            client      = http;
            loggedIn    = false;
            gotInternet = false;

            //debug = true;

            network = new NetworkChanged();

            Windows.Networking.Connectivity.NetworkInformation.NetworkStatusChanged += NetworkStatusChanged;
        }
예제 #11
0
        public API(HttpClient http, string lastVis)
        {
            if (http == null)
            {
                throw new Exception("No client is provided");
            }

            lastPage = lastVis;
            client = http;
            loggedIn = false;
            gotInternet = false;

            //debug = true;

            network = new NetworkChanged();

            Windows.Networking.Connectivity.NetworkInformation.NetworkStatusChanged += NetworkStatusChanged;
        }
예제 #12
0
        public API()
        {
            HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();

            filter.AutomaticDecompression = true;
            HttpClient http = new HttpClient(filter);

            cookieMonster = filter.CookieManager;

            client      = http;
            loggedIn    = false;
            gotInternet = false;

            //debug = true;

            network = new NetworkChanged();

            Windows.Networking.Connectivity.NetworkInformation.NetworkStatusChanged += NetworkStatusChanged;
        }
예제 #13
0
 static NetworkHelper()
 {
     Microsoft.Toolkit.Uwp.Connectivity.NetworkHelper.Instance.NetworkChanged +=
         (sender, e) => DispatcherHelper.ExecuteOnUIThreadAsync(() => NetworkChanged?.Invoke(sender, e));
 }
예제 #14
0
 public void OnNetworkChanged(string ips)
 {
     _ips = GetIpAddressesImpl();
     NetworkChanged?.Invoke(ips);
 }
 private void OnNetworkChange()
 {
     NetworkChanged?.Invoke(this, EventArgs.Empty);
 }
예제 #16
0
 public void OnNetworkChanged(string ips)
 {
     NetworkChanged?.Invoke(ips);
 }