Exemple #1
0
        // accept
        public KChannel(uint localConn, uint remoteConn, Socket socket, IPEndPoint remoteEndPoint, KService kService) : base(kService, ChannelType.Accept)
        {
            this.memoryStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue);

            this.LocalConn      = localConn;
            this.RemoteConn     = remoteConn;
            this.remoteEndPoint = remoteEndPoint;
            this.socket         = socket;
            this.kcp            = Kcp.KcpCreate(this.RemoteConn, new IntPtr(this.LocalConn));

            SetOutput();
            Kcp.KcpNodelay(this.kcp, 1, 10, 1, 1);
            Kcp.KcpWndsize(this.kcp, 256, 256);
            Kcp.KcpSetmtu(this.kcp, 470);
            this.lastRecvTime = kService.TimeNow;
            this.createTime   = kService.TimeNow;
            this.Accept();
        }
        private void InitKcp()
        {
            switch (this.Service.ServiceType)
            {
            case ServiceType.Inner:
                Kcp.KcpNodelay(kcp, 1, 10, 2, 1);
                Kcp.KcpWndsize(kcp, 1024 * 100, 1024 * 100);
                Kcp.KcpSetmtu(kcp, 1400);                         // 默认1400
                Kcp.KcpSetminrto(kcp, 10);
                break;

            case ServiceType.Outer:
                Kcp.KcpNodelay(kcp, 1, 10, 2, 1);
                Kcp.KcpWndsize(kcp, 128, 128);
                Kcp.KcpSetmtu(kcp, 470);
                Kcp.KcpSetminrto(kcp, 10);
                break;
            }
        }
Exemple #3
0
        private void InitKcp()
        {
            KcpPtrChannels.Add(this.kcp, this);
            switch (this.Service.ServiceType)
            {
            case ServiceType.Inner:
                Kcp.KcpNodelay(kcp, 1, 10, 2, 1);
                Kcp.KcpWndsize(kcp, ushort.MaxValue, ushort.MaxValue);
                Kcp.KcpSetmtu(kcp, 1400);                         // 默认1400
                Kcp.KcpSetminrto(kcp, 30);
                break;

            case ServiceType.Outer:
                Kcp.KcpNodelay(kcp, 1, 10, 2, 1);
                Kcp.KcpWndsize(kcp, 256, 256);
                Kcp.KcpSetmtu(kcp, 470);
                Kcp.KcpSetminrto(kcp, 30);
                break;
            }
        }
Exemple #4
0
        public void HandleConnnect(uint remoteConn)
        {
            if (this.isConnected)
            {
                return;
            }

            this.RemoteConn = remoteConn;

            this.kcp = Kcp.KcpCreate(this.RemoteConn, new IntPtr(this.LocalConn));
            SetOutput();
            Kcp.KcpNodelay(this.kcp, 1, 10, 1, 1);
            Kcp.KcpWndsize(this.kcp, 256, 256);
            Kcp.KcpSetmtu(this.kcp, 470);

            this.isConnected  = true;
            this.lastRecvTime = this.GetService().TimeNow;

            HandleSend();
        }