예제 #1
0
        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;
            }
        }
예제 #2
0
파일: WChannel.cs 프로젝트: x1766233/DCET
        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;
        }
예제 #3
0
파일: WChannel.cs 프로젝트: x1766233/DCET
        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;
        }
예제 #4
0
        public void Awake(NetworkProtocol protocol, string address, int packetSize = Packet.PacketSizeLength4)
        {
            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(packetSize, 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);
            }
        }
예제 #5
0
파일: AChannel.cs 프로젝트: x1766233/DCET
 protected AChannel(AService service, ChannelType channelType)
 {
     this.Id          = IdGenerater.GenerateId();
     this.ChannelType = channelType;
     this.Service     = service;
 }