50 lines
1.5 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>
/// 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();
}
}
2022-08-08 17:03:41 +08:00
/// <summary>
/// Sent to the host when a direct connection has been established
/// </summary>
internal class ConnectionEstablished : Packet
{
public int ID { get; set; }
public override PacketType Type => PacketType.ConnectionEstablished;
public override byte[] Serialize()
{
var data = new List<byte>(10);
data.AddInt(ID);
return data.ToArray();
}
public override void Deserialize(byte[] array)
{
var reader = new BitReader(array);
ID = reader.ReadInt32();
}
}
}
}