Skip to content

Commit

Permalink
rudp update config naming
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jul 2, 2024
1 parent 7ab8a44 commit 1fced35
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/rudp/partials/RUDP.ClientTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -156,7 +157,7 @@ ref endpoint

foreach (var ack in ackList)
{
if (ack == Config.OpenBuffer)
if (ack == Config.Syn)
{
feeds++;
}
Expand Down Expand Up @@ -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++)
{
Expand Down Expand Up @@ -495,7 +496,7 @@ private void InitReceiver()

Task.Run(() =>
{
byte[] pingData = { Config.PingBuffer };
byte[] pingData = { Config.Ping };

UpdateTimeoutTimer();

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1fced35

Please sign in to comment.