public void PacketTest1() { var packet = new MinimumAvatarPacket(1, new Vector3(2, 5, 6), 10, new Vector4(2, 4, 3, 120), 0); Assert.True(packet.CheckRange(), "packet.CheckRange()"); var packets = new List <MinimumAvatarPacket> { packet }; var buff = Utility.PacketsToBuffer(ref packets); var decodedPacket = Utility.BufferToPackets(buff); Assert.Equal(packet.PaketId, decodedPacket ![0].PaketId);
protected override async Task Update(int count) { try { var tasks = new List <Task>(); var packet = new MinimumAvatarPacket(id, _position, (0 + count) % 127, new Vector4(), 0); if (!packet.CheckRange()) { throw new MinimumAvatarPacketCreativeException("the value must be less than or equal to 127 in absolute value."); } var buf = Utility.PacketToBuffer(packet); tasks.Add(udp.SendAsync(buf, buf.Length)); await Task.WhenAll(tasks); } catch (OperationCanceledException) { Printer.PrintDbg("Sender stopped"); throw; } catch (SocketException) { Printer.PrintDbg("Waiting for remote"); } }