Skip to content

Commit

Permalink
update rudp update manager
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jul 5, 2024
1 parent c43d81f commit 7312558
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion src/rudp/partials/utils/RUDP.Connection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Sockets;
using System.Threading.Tasks;
Expand Down Expand Up @@ -278,22 +279,61 @@ private void Update()
if (_isUpdating) return;
_isUpdating = true;

var updateReliableStopwatch = new Stopwatch();
var sendPingStopwatch = new Stopwatch();

const int updateReliableTimerMs = 10;
const int sendPingTimerMs = 75;

while (_isUpdating)
{
try
{
UpdateInjection();
UpdateReliable();
}
catch (Exception e)
{
NetlyEnvironment.Logger.Create(e);
}

try
{
if (updateReliableStopwatch.ElapsedMilliseconds >= updateReliableTimerMs)
{
UpdateReliable();
updateReliableStopwatch.Restart();
}
}
catch (Exception e)
{
NetlyEnvironment.Logger.Create(e);
}

try
{
if (sendPingStopwatch.ElapsedMilliseconds >= sendPingTimerMs)
{
SendPing();
sendPingStopwatch.Restart();
}
}
catch (Exception e)
{
NetlyEnvironment.Logger.Create(e);
}
}

// LOOP END!

updateReliableStopwatch.Stop();
sendPingStopwatch.Stop();
_isUpdating = false;
}

private void SendPing()
{
}

private void UpdateInjection()
{
byte[][] buffers;
Expand Down

0 comments on commit 7312558

Please sign in to comment.