// UDP public void UdpAuth(long session, string ip, int port) { UnityEngine.Debug.Assert(_udpflag == false); UnityEngine.Debug.Assert(_udp == null); _udpsession = session; _udpip = ip; _udpport = port; TimeSync ts = _ctx.TiSync; _udp = new PackageSocketUdp(_ctx, _user.Secret, (uint)session); _udp.OnRecv = UdpRecv; _udp.OnSync = UdpSync; UnityEngine.Debug.Assert(_udp != null); _udp.Connect(ip, port); _udp.Sync(); }
private int _delta = 25; // 0.025s public PackageSocketUdp(Context ctx, byte[] secret, uint session) { _ctx = ctx; _timeSync = _ctx.TiSync; _so = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _secret = secret; _session = session; _u = new Rudp.Rudp(_ctx.SharpC, 1, 5); _u.OnRecv = RRecv; _u.OnSend = RSend; int now = _timeSync.LocalTime(); _last = now; }