38 lines
1.0 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
namespace RageCoop.Core
{
internal partial class Packets
{
2022-08-06 11:40:38 +08:00
/// <summary>
/// Used to measure the connection latency
/// </summary>
internal class PingPong : Packet
{
2022-08-06 10:49:55 +08:00
public override PacketType Type => PacketType.PingPong;
2022-08-06 11:40:38 +08:00
}
/// <summary>
/// Request direct connection to another client
/// </summary>
internal class ConnectionRequest : Packet
{
public int TargetID { get; set; }
public override PacketType Type => PacketType.ConnectionRequest;
2022-08-06 10:43:24 +08:00
public override byte[] Serialize()
{
2022-08-06 11:40:38 +08:00
var data=new List<byte>(10);
data.AddInt(TargetID);
return data.ToArray();
}
2022-08-06 10:43:24 +08:00
public override void Deserialize(byte[] array)
{
2022-08-06 11:40:38 +08:00
var reader=new BitReader(array);
TargetID = reader.ReadInt32();
}
}
}
}