Skip to content

Commit

Permalink
rudp send ping implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jul 5, 2024
1 parent 7312558 commit cdfede1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/rudp/partials/utils/RUDP.Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ private void Update()

private void SendPing()
{
var primitive = new Primitive();
primitive.Add.Byte(PingByte);
primitive.Add.Float(InternalActionKey);
var bytes = primitive.GetBytes();
Send(ref bytes, MessageType.Unreliable);
}

private void UpdateInjection()
Expand Down Expand Up @@ -378,6 +383,21 @@ private void UpdateInjection()
// check is the flag
switch (tag)
{
case PingByte:
{
var key = myPrimitive.Get.Float();

if (myPrimitive.IsValid && InternalActionKey.Equals(key))
{
isInternalAction = true;

// update latest ping received timer
// TODO implement this.
}

break;
}

case DataAckByte:
{
uint dataAckId = myPrimitive.Get.UInt();
Expand Down

0 comments on commit cdfede1

Please sign in to comment.