From 1fced35685c7a71e7c6ab57051404aece06aeaa2 Mon Sep 17 00:00:00 2001 From: "Alecio Furanze (Ale)" Date: Tue, 2 Jul 2024 22:29:13 +0200 Subject: [PATCH] rudp update config naming --- src/rudp/partials/RUDP.ClientTo.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/rudp/partials/RUDP.ClientTo.cs b/src/rudp/partials/RUDP.ClientTo.cs index 6470183..e12fcc5 100644 --- a/src/rudp/partials/RUDP.ClientTo.cs +++ b/src/rudp/partials/RUDP.ClientTo.cs @@ -49,11 +49,12 @@ private readonly object private struct Config { - public const byte PingBuffer = 0; - public const byte OpenBuffer = 128; - public const byte CloseBuffer = 255; + public const byte Ping = 0; + public const byte Syn = 1; + public const byte Ack = 2; + public const byte Fin = 4; public const byte OpenRepeat = 32; - public const byte CloseRepeat = 32; + public const byte CloseRepeat = 8; } private class Package @@ -110,7 +111,7 @@ public Task Open(Host host) _socket.Connect(host.Address, host.Port); // create connection data - var data = new byte[] { Config.OpenBuffer }; + var data = new byte[] { Config.Syn }; // send connected data for (int i = 0; i < Config.OpenRepeat; i++) @@ -156,7 +157,7 @@ ref endpoint foreach (var ack in ackList) { - if (ack == Config.OpenBuffer) + if (ack == Config.Syn) { feeds++; } @@ -213,7 +214,7 @@ public Task Close() { try { - var data = new[] { Config.CloseBuffer }; + var data = new[] { Config.Fin }; for (var i = 0; i < Config.CloseRepeat; i++) { @@ -495,7 +496,7 @@ private void InitReceiver() Task.Run(() => { - byte[] pingData = { Config.PingBuffer }; + byte[] pingData = { Config.Ping }; UpdateTimeoutTimer(); @@ -597,20 +598,20 @@ private void ProcessBuffer(ref byte[] data) { byte key = data[0]; - if (key == Config.CloseBuffer) + if (key == Config.Fin) { Close(); return; } - if (key == Config.OpenBuffer) + if (key == Config.Syn) { - byte[] bytes = { Config.OpenBuffer }; + byte[] bytes = { Config.Ack }; SendRaw(Host, ref bytes); return; } - if (key == Config.PingBuffer) + if (key == Config.Ping) { UpdateTimeoutTimer(); return;