public override void OnTick(ulong nowUsec) { Tonk.Status status = GetStatus(); if (++StatusLogCounter >= 100) { StatusLogCounter = 0; TestTools.LogTonkStatus(this); if (status.Flags.HasFlag(Tonk.Flags.TimeSync)) { if (!Client.StartedP2PConnection) { // Tell server we want to connect to another peer byte[] data = new byte[1]; data[0] = Constants.ID_P2PConnectionStart; Send(data); } } } if (Constants.TONK_ENABLE_1MBPS_DATA) { if (status.Flags.HasFlag(Tonk.Flags.TimeSync)) { byte[] data = new byte[1 + 2 + 3 + 1300 - 4]; for (int i = 0; i < data.Length; ++i) { data[i] = (byte)i; } UInt16 ts16 = ToRemoteTime16(nowUsec); UInt32 ts23 = ToRemoteTime23(nowUsec); data[0] = 1; unsafe { fixed(byte *ptr = data) { Tonk.WriteU16_LE(ptr + 1, ts16); Tonk.WriteU24_LE(ptr + 1 + 2, ts23); Tonk.WriteU24_LE(ptr + 1 + 2 + 3, 0x123456); Tonk.WriteU32_LE(ptr + 1 + 2 + 3 + 3, MBCounter++); } } Send(data); } } // Test destroying the object before app shuts down. // Ensure that GC collects the SDKConnection object shortly after this. //Close(); }
public override void OnTick(ulong nowUsec) { Tonk.Status status = GetStatus(); if (++StatusLogCounter >= 100) { StatusLogCounter = 0; TestTools.LogTonkStatus(this); } if (Constants.TONK_ENABLE_1MBPS_DATA) { if (status.Flags.HasFlag(Tonk.Flags.TimeSync)) { byte[] data = new byte[1 + 2 + 3 + 1300 - 4]; for (int i = 0; i < data.Length; ++i) { data[i] = (byte)i; } UInt16 ts16 = ToRemoteTime16(nowUsec); UInt32 ts23 = ToRemoteTime23(nowUsec); unsafe { fixed(byte *ptr = data) { ptr[0] = 1; Tonk.WriteU16_LE(ptr + 1, ts16); Tonk.WriteU24_LE(ptr + 1 + 2, ts23); Tonk.WriteU24_LE(ptr + 1 + 2 + 3, 0x123456); Tonk.WriteU32_LE(ptr + 1 + 2 + 3 + 3, MBCounter++); } } Send(data); } } }