示例#1
0
 /// <summary>
 /// 构建KCP服务器
 /// </summary>
 /// <param name="conv">可以看成客户端的id kcp 的(uint)id </param>
 public KcpService(uint conv)
 {
     mKCP = new KCP(conv, (byte[] data, int length) =>
     {
         if (IsConnected)
         {
             Send(data, length);
         }
     });
     mKCP.NoDelay(1, 10, 2, 1);
 }
示例#2
0
        public void Connect(UInt32 conv, string host, UInt16 port)
        {
            var addr = IPAddress.Parse(host);

            remoteEnd = new IPEndPoint(addr, port);
            socket    = new Socket(addr.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
            socket.Connect(remoteEnd);

            kcp = new KCP(conv, this);
            kcp.SetOutput(OutputKCP);

            // fast mode
            kcp.NoDelay(1, 10, 2, 1);
            kcp.WndSize(128, 128);
        }
示例#3
0
        public Session(int id, Socket sock, NetworkService serv)
        {
            mID      = id;
            mService = serv;
            mSocket  = sock;

            tcpAdress     = (IPEndPoint)sock.RemoteEndPoint;
            mActiveThread = new Thread(ActiveThread);

            mActiveThread.Start();

            if (mService.kcp != null)
            {
                mKCP = new KCP((uint)id, OnSendKcp);
                mKCP.NoDelay(1, 10, 2, 1);
            }
        }
示例#4
0
 public KcpService(Client service, uint conv)
 {
     mService = service;
     mKCP     = new KCP(conv, OnSendKcp);
     mKCP.NoDelay(1, 10, 2, 1);
 }