예제 #1
0
        private void OnSocketOnDisconnected(IHyperSocket socket, IDisconnectedEventArgs args)
        {
            Action <ITypedSocket, IDisconnectedEventArgs> evnt = Disconnected;

            if (evnt != null)
            {
                evnt(this, args);
            }
        }
예제 #2
0
        public async Task <bool> Disconnected(MiraiHttpSession session, IDisconnectedEventArgs e)
        {
            // e.Exception: 引发掉线的响应异常, 按需处理
            MiraiHttpSessionOptions options = new MiraiHttpSessionOptions(Setting.Host, Setting.Port, Setting.AuthKey);

            while (true)
            {
                try
                {
                    await session.ConnectAsync(options, Setting.QQ); // 连到成功为止, QQ号自填, 你也可以另行处理重连的 behaviour

                    return(true);
                }
                catch (Exception)
                {
                    await Task.Delay(1000);
                }
            }
        }
예제 #3
0
        public async Task <bool> Disconnected(MiraiHttpSession session, IDisconnectedEventArgs e)
        {
            // e.Exception: 引发掉线的响应异常, 按需处理
            MiraiHttpSessionOptions options = new MiraiHttpSessionOptions("47.242.52.67", 5200, "zheng12321");

            while (true)
            {
                try
                {
                    await session.ConnectAsync(options, 2033593308); // 连到成功为止, QQ号自填, 你也可以另行处理重连的 behaviour

                    return(true);
                }
                catch (Exception)
                {
                    await Task.Delay(1000);
                }
            }
        }
예제 #4
0
        public async Task <bool> Disconnected(MiraiHttpSession session, IDisconnectedEventArgs e)
        {
            // e.Exception: 引发掉线的响应异常, 按需处理
            MiraiHttpSessionOptions options = new MiraiHttpSessionOptions("127.0.0.1", 33111, "8d726307dd7b468d8550a95f236444f7");

            while (true)
            {
                try
                {
                    await session.ConnectAsync(options, 0); // 连到成功为止, QQ号自填, 你也可以另行处理重连的 behaviour

                    return(true);
                }
                catch (Exception)
                {
                    await Task.Delay(1000);
                }
            }
        }
        public async Task <bool> Disconnected(MiraiHttpSession session, IDisconnectedEventArgs e)
        {
            // e.Exception: 引发掉线的响应异常, 按需处理
            MiraiHttpSessionOptions options = new MiraiHttpSessionOptions("mirai-api.duwanjuan.cn", 80, "chapanzhou");

            while (true)
            {
                try
                {
                    await session.ConnectAsync(options, 1493513606); // 连到成功为止, QQ号自填, 你也可以另行处理重连的 behaviour

                    return(true);
                }
                catch (Exception ex)
                {
                    await Task.Delay(1000);
                }
            }
        }
예제 #6
0
        public async Task <bool> Disconnected(MiraiHttpSession session, IDisconnectedEventArgs e)
        {
            logger.LogError("已断开连接,正在尝试重连");
            MiraiHttpSessionOptions options = new MiraiHttpSessionOptions(miraiSessionOptions.Value.MiraiHost, miraiSessionOptions.Value.MiraiHostPort, miraiSessionOptions.Value.MiraiSessionKey);

            while (true)
            {
                try
                {
                    await session.ConnectAsync(options, miraiSessionOptions.Value.MiraiSessionQQ);

                    logger.LogInformation("重连成功");
                    return(true);
                }
                catch (Exception)
                {
                    await Task.Delay(1000);
                }
            }
        }
예제 #7
0
 public async Task HandleMessageAsync(IMiraiHttpSession client, IDisconnectedEventArgs message)
 {
     _logger.Error("disconnected, reconnecting");
     await client.ConnectAsync(client.QQNumber.Value);
 }