mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
add packet loss test
This commit is contained in:
parent
43ac9d1c0d
commit
4d50945e01
@ -10,6 +10,7 @@ using QSB.ShipSync;
|
||||
using QSB.Utility.Messages;
|
||||
using QSB.WorldSync;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@ -200,7 +201,10 @@ public class DebugActions : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
if (Keyboard.current[Key.Numpad4].wasPressedThisFrame)
|
||||
{
|
||||
DamageShipElectricalSystem();
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
StartCoroutine(SendPacketLossTest());
|
||||
}
|
||||
}
|
||||
|
||||
if (Keyboard.current[Key.Numpad5].wasPressedThisFrame)
|
||||
@ -242,4 +246,21 @@ public class DebugActions : MonoBehaviour, IAddComponentOnStart
|
||||
RespawnManager.Instance.RespawnSomePlayer();
|
||||
}
|
||||
}
|
||||
|
||||
const int MAX_MESSAGES = 100;
|
||||
|
||||
int currentMessage = 1;
|
||||
|
||||
public static int TotalMessages;
|
||||
|
||||
IEnumerator SendPacketLossTest()
|
||||
{
|
||||
DebugLog.DebugWrite($"STARTING DROPPED MESSAGE TEST...");
|
||||
while (currentMessage <= MAX_MESSAGES)
|
||||
{
|
||||
new PacketLossTestMessage().Send();
|
||||
currentMessage++;
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
QSB/Utility/Messages/PacketLossTestMessage.cs
Normal file
23
QSB/Utility/Messages/PacketLossTestMessage.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using QSB.Messaging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QSB.Utility.Messages;
|
||||
|
||||
internal class PacketLossTestMessage : QSBMessage
|
||||
{
|
||||
public override void OnReceiveLocal()
|
||||
{
|
||||
DebugActions.TotalMessages += 1;
|
||||
DebugLog.DebugWrite($"Total test messages sent is now {DebugActions.TotalMessages}");
|
||||
}
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
DebugActions.TotalMessages += 1;
|
||||
DebugLog.DebugWrite($"Total test messages recieved is now {DebugActions.TotalMessages}");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user