public WcpChannel(string httpPrefixed, WebSocket socket, ANetService netService) : base(netService) { this.HttpPrefixed = httpPrefixed; this.NetSocket = socket; this.RecvParser = ParserStorage.GetParser(); this.SendParser = ParserStorage.GetParser(); }
public async override void Disconnect() { if (!this.Connected) { return; } if (NetSocket == null) { return; } this.Connected = false; //服务端连接断开把缓冲区丢进池 if (this.NetService.ServiceType == NetServiceType.Server) { ParserStorage.Push(SendParser); ParserStorage.Push(RecvParser); } else { this.SendParser.Clear(); this.RecvParser.Clear(); } await SendClose(this.NetSocket); await this.SyncContext; this.OnDisconnected(this); }
/// <summary> /// 断开连接 /// </summary> public override void Disconnect() { if (!this.Connected) { return; } this.Connected = false; this.OnDisconnected?.Invoke(this); ConnectSender.SendFIN(this.SendParser.Packet, this.NetSocket, this.RemoteEndPoint, this.Id); //服务端连接断开把缓冲区丢进池 if (this.NetService.ServiceType == NetServiceType.Server) { ParserStorage.Push(this.SendParser); ParserStorage.Push(this.RecvParser); } else { this.SendParser.Clear(); this.RecvParser.Clear(); } KCP.KcpRelease(this.Kcp); this.Kcp = IntPtr.Zero; }
public override void Disconnect() { if (!this.Connected) { return; } if (this.NetSocket == null) { return; } this.Connected = false; this.OnDisconnected?.Invoke(this); //服务端连接断开把缓冲区丢进池 if (this.NetService.ServiceType == NetServiceType.Server) { ParserStorage.Push(this.SendParser); ParserStorage.Push(this.RecvParser); } else { this.SendParser.Clear(); this.RecvParser.Clear(); } this.NetSocket.Close(); this.NetSocket.Dispose(); this.NetSocket = null; this.InArgs.Dispose(); this.OutArgs.Dispose(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="socket">Socket</param> /// <param name="netService">网络服务</param> /// <param name="connectConv">网络连接Conv</param> public KcpChannel(Socket socket, IPEndPoint endPoint, ANetService netService, int connectConv) : base(netService, connectConv) { this.RemoteEndPoint = endPoint; this.NetSocket = socket; this.RecvParser = ParserStorage.GetParser(1400); this.SendParser = ParserStorage.GetParser(1400); }
/// <summary> /// 构造函数,Accept /// </summary> /// <param name="endPoint">IP/端口</param> /// <param name="socket">TCP socket类</param> /// <param name="netService">通讯网络服务对象</param> public TcpChannel(IPEndPoint endPoint, Socket socket, ANetService netService) : base(netService) { this.LocalEndPoint = endPoint; this.RecvParser = ParserStorage.GetParser(); this.SendParser = ParserStorage.GetParser(); this.NetSocket = socket; this.InArgs = new SocketAsyncEventArgs(); this.OutArgs = new SocketAsyncEventArgs(); this.InArgs.Completed += OnComplete; this.OutArgs.Completed += OnComplete; }
public WcpChannel(string httpPrefixed, ANetService netService, Network network) : base(netService, network) { this.HttpPrefixed = httpPrefixed; this.RecvParser = ParserStorage.GetParser(); this.SendParser = ParserStorage.GetParser(); }
/// <summary> /// 构造函数,Connect /// </summary> /// <param name="endPoint">Ip/端口</param> /// <param name="netService">通讯网络服务对象</param> /// <param name="network">网络类</param> public TcpChannel(IPEndPoint endPoint, ANetService netService, Network network) : base(netService, network) { this.RemoteEndPoint = endPoint; this.RecvParser = ParserStorage.GetParser(); this.SendParser = ParserStorage.GetParser(); }