From cdfede1f745558793065b8e6337d33ac5fd6442f Mon Sep 17 00:00:00 2001 From: "Alecio Furanze (Ale)" Date: Fri, 5 Jul 2024 22:25:00 +0200 Subject: [PATCH] rudp send ping implemented --- src/rudp/partials/utils/RUDP.Connection.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/rudp/partials/utils/RUDP.Connection.cs b/src/rudp/partials/utils/RUDP.Connection.cs index 447b170..a9f66b7 100644 --- a/src/rudp/partials/utils/RUDP.Connection.cs +++ b/src/rudp/partials/utils/RUDP.Connection.cs @@ -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() @@ -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();