public Connection(IPEndPoint endPoint, Action <IPEndPoint, byte[], int> Send, Action <IPEndPoint, byte, byte[]> Handle) { this.EndPoint = endPoint; this.heartbeat = true; this.kcp = new KCP(1, (byte[] buffer, int size) => Send(this.EndPoint, buffer, size)); this.kcp.NoDelay(1, 10, 2, 1); this.kcp.WndSize(128, 128); this.Handle = (byte id, byte[] data) => Handle(this.EndPoint, id, data); }
public bool Connect() { if (this.Connected) { return(false); } this.udp = new UdpClient(this.addr, this.port); this.kcp = new KCP(1, this.SendWrap); this.kcp.NoDelay(1, 10, 2, 1); this.kcp.WndSize(128, 128); this.Send(EventCode.Connect); this.Receive(); this.updateTime = 0; this.Connected = true; return(true); }