public void Awake(NetworkProtocol protocol) { switch (protocol) { case NetworkProtocol.KCP: this.Service = new KService() { Parent = this }; break; case NetworkProtocol.TCP: this.Service = new TService() { Parent = this }; break; case NetworkProtocol.WebSocket: this.Service = new WService() { Parent = this }; break; } }
public WChannel(WebSocket webSocket, AService service) : base(service, ChannelType.Connect) { this.webSocket = webSocket; this.memoryStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); this.recvStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); isConnected = false; }
public WChannel(HttpListenerWebSocketContext webSocketContext, AService service) : base(service, ChannelType.Accept) { this.WebSocketContext = webSocketContext; this.webSocket = webSocketContext.WebSocket; this.memoryStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); this.recvStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); isConnected = true; }
public void Awake(NetworkProtocol protocol, string address) { try { IPEndPoint ipEndPoint; switch (protocol) { case NetworkProtocol.KCP: ipEndPoint = NetworkHelper.ToIPEndPoint(address); this.Service = new KService(ipEndPoint, (channel) => { this.OnAccept(channel); }) { Parent = this }; break; case NetworkProtocol.TCP: ipEndPoint = NetworkHelper.ToIPEndPoint(address); this.Service = new TService(ipEndPoint, (channel) => { this.OnAccept(channel); }) { Parent = this }; break; case NetworkProtocol.WebSocket: string[] prefixs = address.Split(';'); this.Service = new WService(prefixs, (channel) => { this.OnAccept(channel); }) { Parent = this }; break; } } catch (Exception e) { throw new Exception($"NetworkComponent Awake Error {address}", e); } }
protected AChannel(AService service, ChannelType channelType) { this.Id = IdGenerater.GenerateId(); this.ChannelType = channelType; this.Service = service; }