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;
            }
        }
Exemple #2
0
        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;
            }
        }
Exemple #3
0
        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;
        }
Exemple #4
0
        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;
        }
Exemple #5
0
        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} ");
        }
Exemple #6
0
 public static void Remove(this NetThreadComponent self, AService kService)
 {
     // 这里要去下一帧删除,避免foreach错误
     self.ThreadSynchronizationContext.PostNext(() =>
     {
         if (kService.IsDispose())
         {
             return;
         }
         self.Services.Remove(kService);
     });
 }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
 public PacketParser(CircularBuffer buffer, AService service)
 {
     this.buffer       = buffer;
     this.service      = service;
     cacheMemoryStream = new MemoryStream(8);
 }
Exemple #9
0
 public PacketParser(CircularBuffer buffer, AService service)
 {
     this.buffer  = buffer;
     this.service = service;
 }
Exemple #10
0
 protected AChannel(AService service, ChannelType channelType)
 {
     this.Id          = IdGenerater.GenerateId();
     this.ChannelType = channelType;
     this.Service     = service;
 }