/// <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); }
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); }
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); } }
public KcpService(Client service, uint conv) { mService = service; mKCP = new KCP(conv, OnSendKcp); mKCP.NoDelay(1, 10, 2, 1); }