public void Awake(NetworkProtocol protocol, int packetSize = Packet.PacketSizeLength4) { switch (protocol) { case NetworkProtocol.KCP: this.Service = new KService() { Parent = this }; break; case NetworkProtocol.TCP: this.Service = new TService(packetSize) { Parent = this }; break; case NetworkProtocol.WebSocket: this.Service = new WService() { Parent = this }; break; } }
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(AService aService) { this.AService = aService; long timeNow = TimeHelper.ClientNow(); this.LastRecvTime = timeNow; this.LastSendTime = timeNow; this.requestCallbacks.Clear(); Log.Info($"session create: zone: {this.DomainZone()} id: {this.Id} {timeNow} "); }
public static void Remove(this NetThreadComponent self, AService kService) { // 这里要去下一帧删除,避免foreach错误 self.ThreadSynchronizationContext.PostNext(() => { if (kService.IsDispose()) { return; } self.Services.Remove(kService); }); }
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); } }
public PacketParser(CircularBuffer buffer, AService service) { this.buffer = buffer; this.service = service; cacheMemoryStream = new MemoryStream(8); }
public PacketParser(CircularBuffer buffer, AService service) { this.buffer = buffer; this.service = service; }
protected AChannel(AService service, ChannelType channelType) { this.Id = IdGenerater.GenerateId(); this.ChannelType = channelType; this.Service = service; }