コード例 #1
0
ファイル: KcpService.cs プロジェクト: HeNuoScott/Net3DGame
 /// <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);
 }