Ejemplo 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);
        }
Ejemplo n.º 2
0
 public void Close()
 {
     if (m_asyncServer != null)
     {
         AsyncServer.CloseClientSocket(this);
     }
     MatchRTUCount = 0;
     ClearBuffer();
     DisConnected?.Invoke(this, new EventArgs());
 }
Ejemplo 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());
 }
Ejemplo 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;
     }
 }
Ejemplo n.º 5
0
 //切断する
 public void DisConnect()
 {
     if (client == null)
     {
         return;
     }
     Thread.Sleep(1000);
     networkStream.Close();
     client.Close();
     client = null;
     DisConnected?.Invoke();
 }
Ejemplo n.º 6
0
		static extern void regOnDisConnected(DisConnected dc);
Ejemplo n.º 7
0
 private void RaiseDisConnected(string info)
 {
     DisConnected?.Invoke(info);
 }
Ejemplo n.º 8
0
 protected void OnDisConnected()
 {
     DisConnected?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 9
0
 public static void SetDisConnectedCall(DisConnected callback = null)
 {
     DisConnectedHandler = callback;
 }