示例#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;
 }