Exemplo n.º 1
0
        public override async void DisconnectAsync(string msg = "Powered by WinIRC", bool attemptReconnect = false)
        {
            WriteLine("QUIT :" + msg);
            IsConnected = false;

            if (attemptReconnect)
            {
                IsConnecting = true;
                if (ConnCheck.HasInternetAccess)
                {
                    ReconnectionAttempts++;

                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, async() =>
                    {
                        if (ReconnectionAttempts < 3)
                        {
                            await Task.Delay(1000);
                        }
                        else
                        {
                            await Task.Delay(60000);
                        }

                        Connect();
                    });
                }
            }
            else
            {
                HandleDisconnect?.Invoke(this);
                messageWebSocket.Dispose();
            }
        }
Exemplo n.º 2
0
        public override async void DisconnectAsync(string msg = "Powered by WinIRC", bool attemptReconnect = false)
        {
            WriteLine("QUIT :" + msg);
            IsConnected = false;

            if (attemptReconnect)
            {
                IsConnecting = true;
                ReconnectionAttempts++;
                if (ConnCheck != null && Server != null && ConnCheck.HasInternetAccess)
                {
                    await WindowWrapper.Current().Dispatcher.DispatchAsync(async() => {
                        if (ReconnectionAttempts < 3)
                        {
                            await Task.Delay(1000);
                        }
                        else
                        {
                            await Task.Delay(60000);
                        }

                        if (IsReconnecting)
                        {
                            Connect();
                        }
                    });
                }
            }
            else
            {
                IsConnecting = false;
                HandleDisconnect?.Invoke(this);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// socket断开了连接。发送消息超时判断为socket断开连接
 /// </summary>
 protected virtual void OnSocketDisconnected()
 {
     _socketClient.Close();
     StopHeartbeat();
     Reconnect();
     if (HandleDisconnect != null)
     {
         HandleDisconnect.Invoke();
     }
 }
Exemplo n.º 4
0
 public void OnDisconnect()
 {
     if (HandleDisconnect == null)
     {
         Logger.Debug($"{nameof(HandleDisconnect)}没添加事件!");
     }
     else
     {
         HandleDisconnect.Invoke();
     }
 }