/// <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); }
public void Close() { if (m_asyncServer != null) { AsyncServer.CloseClientSocket(this); } MatchRTUCount = 0; ClearBuffer(); DisConnected?.Invoke(this, new EventArgs()); }
/// <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()); }
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(); }
private void RaiseDisConnected(string info) { DisConnected?.Invoke(info); }
protected void OnDisConnected() { DisConnected?.Invoke(this, EventArgs.Empty); }