Esempio n. 1
0
        /// <summary>
        /// 与服务端失联后,触发
        /// </summary>
        /// <param name="context"></param>
        public void OnChannelInactiveHandler(IChannelHandlerContext context)
        {
            DisConnectedArgs args = new DisConnectedArgs();

            args.EndPoint  = context.Channel.RemoteAddress;
            args.ContextId = context.Channel.Id.AsLongText();
            DisConnected?.Invoke(this, args);
            RetryConnect(this, args);
        }
Esempio n. 2
0
 public void Close()
 {
     if (m_asyncServer != null)
     {
         AsyncServer.CloseClientSocket(this);
     }
     MatchRTUCount = 0;
     ClearBuffer();
     DisConnected?.Invoke(this, new EventArgs());
 }
Esempio n. 3
0
 /// <summary>
 /// 取消连接
 /// </summary>
 public void DisConnect()
 {
     if (Status == NetStatus.Connected)
     {
         TcpClient.Client.Disconnect(false);
     }
     TcpClient.Close();
     TcpClient = new TcpClient();
     Status    = NetStatus.DisConnected;
     DisConnected?.Invoke(this, new EventArgs());
 }
Esempio n. 4
0
 public void Disconnect(string ip)
 {
     if (ConnectingList.ContainsKey(ip))
     {
         ConnectingList[ip].Disconnect(true);
         // ConnectingList[ip].Shutdown(SocketShutdown.Both);
         ConnectingList[ip].Close();
         DisConnected?.Invoke(this, new DisConnectedArgs(ip));
         ConnectingList.Remove(ip);
         ConnectedCount -= 1;
     }
 }
 //切断する
 public void DisConnect()
 {
     if (client == null)
     {
         return;
     }
     Thread.Sleep(1000);
     networkStream.Close();
     client.Close();
     client = null;
     DisConnected?.Invoke();
 }
Esempio n. 6
0
 private void RaiseDisConnected(string info)
 {
     DisConnected?.Invoke(info);
 }
Esempio n. 7
0
 protected void OnDisConnected()
 {
     DisConnected?.Invoke(this, EventArgs.Empty);
 }