/// <summary> /// 构造函数,KCP Accept /// </summary> /// <param name="netService">网络通讯服务对象</param> /// <param name="conv">KCP连接确认号Conv</param> public ANetChannel(ANetService netService, int conv) { this.NetService = netService; Id = conv; this.Network = new Network(this); this.Network.Channel = this; }
public WcpChannel(string httpPrefixed, WebSocket socket, ANetService netService) : base(netService) { this.HttpPrefixed = httpPrefixed; this.NetSocket = socket; this.RecvParser = ParserStorage.GetParser(); this.SendParser = ParserStorage.GetParser(); }
/// <summary> /// 构造函数,TCP Accept /// </summary> /// <param name="netService">网络通讯服务对象</param> public ANetChannel(ANetService netService) { this.NetService = netService; Id = ChannelIdCreator.CreateId(); this.Network = new Network(this); this.Network.Channel = this; }
/// <summary> /// 构造函数,KCP Connect /// </summary> /// <param name="netService">网络通讯服务对象</param> /// <param name="conv">KCP连接确认号Conv</param> public ANetChannel(ANetService netService, Network network, int conv) { this.NetService = netService; Id = conv; this.Network = network; this.Network.Channel = this; }
/// <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; }
/// <summary> /// 连接服务器 /// </summary> /// <param name="endPoint"></param> /// <returns></returns> public void Connect() { if (this.PType == ProtocalType.Tcp) { this.NService = new TcpService(this.EPoint, this, this.Network, NetServiceType.Client); } else if (this.PType == ProtocalType.Kcp) { this.NService = new KcpService(this.EPoint, this, this.Network, NetServiceType.Client); } else if (this.PType == ProtocalType.Wcp) { this.NService = new WcpService(this.HttpPrefixed, this, this.Network, NetServiceType.Client); } this.NService.OnClientDisconnected = (c) => { this.OnClientDisconnected?.Invoke(c.Network); }; this.NService.OnClientConnected = (c) => { OnClientConnected?.Invoke(c.Network); }; this.ConnectChannel = this.NService.Connect(); }
/// <summary> /// 开始监听并接受客户端连接 /// </summary> /// <param name="endPoint"></param> public bool Accept() { if (this.PType == ProtocalType.Tcp) { this.NService = new TcpService(this.EPoint, this, this.Network, NetServiceType.Server); } else if (this.PType == ProtocalType.Kcp) { this.NService = new KcpService(this.EPoint, this, this.Network, NetServiceType.Server); } else if (this.PType == ProtocalType.Wcp) { this.NService = new WcpService(this.HttpPrefixed, this, this.Network, NetServiceType.Server); } this.NService.OnServerConnected = (c) => { this.OnServerConnected?.Invoke(c.Network); }; this.NService.OnServerDisconnected = (c) => { this.OnServerDisconnected?.Invoke(c.Network); }; this.NService.Accept(); return(true); }
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(); }
public void Dispose() { this.NService.Dispose(); this.NService = null; }