Get CLI to a base state

This commit is contained in:
derek.holloway committed 2026-08-07 13:20:32 -07:00
1 parent 068c88de4b
commit c8a0aef289
2 files changed
+28 -13

No files matched your search

+12 -2
View File
@@ -12,7 +12,11 @@ class clientExample {
}
void onClientConnected(mUDPClient user) {
Console.WriteLine("User connected with username: " + user.UserName);
Console.WriteLine("User connected to server with username: " + user.UserName);
}
void onClientJoined(mUDPClient user) {
Console.WriteLine("User is now in range of you and UDP connections started with user : " + user.UserName);
}
void onReceive(mUDPClient? user, dynamic data) {
@@ -29,8 +33,12 @@ class clientExample {
}
}
void onClientLeft(mUDPClient user) {
Console.WriteLine("User is no longer in range of you and UDP connections ended with user : " + user.UserName);
}
void onClientDisconnected(mUDPClient user) {
Console.WriteLine("User disconnected with username: " + user.UserName);
Console.WriteLine("User disconnected from server with username: " + user.UserName);
}
void onServerDisconnected() {
@@ -42,7 +50,9 @@ class clientExample {
if (clientObject == null) return;
clientObject.onServerConnected += onServerConnected;
clientObject.onUserConnected += onClientConnected;
clientObject.onUserJoined += onClientJoined;
clientObject.onDataReceived += onReceive;
clientObject.onUserLeft += onClientLeft;
clientObject.onUserDisconnected += onClientDisconnected;
clientObject.onServerDisconnected += onServerDisconnected;
}
+16 -11
View File
@@ -6,6 +6,7 @@ using System.Net.Sockets;
using System.Numerics;
using System.Threading;
using System.Threading.Tasks;
using MessagePack.Formatters;
using Mistox.ResevedPackets;
namespace Mistox.Client {
@@ -95,13 +96,17 @@ namespace Mistox.Client {
if (!clientConnections.ContainsKey(remoteHost)) {
mUDPClient newConnection = new mUDPClient(this, remoteHost);
clientConnections[remoteHost] = newConnection;
InvokeOnUserJoined(newConnection);
}
}
// Remove users that left
foreach (IPEndPoint key in clientConnections.Keys) {
if (!activeIps.Contains(key.Address)) {
clientConnections.TryRemove(key, out _);
mUDPClient? user;
clientConnections.TryRemove(key, out user);
if (user == null) return;
InvokeOnUserLeft(user);
}
}
@@ -155,15 +160,15 @@ namespace Mistox.Client {
}
// When any user connects to the server (self) hasn't seen yet
public event Action<string> onUserJoined;
public void InvokeOnUserJoined(string UserName){
onUserJoined?.Invoke(UserName);
public event Action<mUDPClient> onUserJoined;
public void InvokeOnUserJoined(mUDPClient User){
onUserJoined?.Invoke(User);
}
// When user is within range of (self) and network rendering starts
public event Action<mUDPClient> onUserConnected;
public void InvokeOnUserConnected(mUDPClient ConnectedUser){
onUserConnected?.Invoke(ConnectedUser);
public void InvokeOnUserConnected(mUDPClient User){
onUserConnected?.Invoke(User);
}
// When generic data is received
@@ -189,14 +194,14 @@ namespace Mistox.Client {
// When user is no longer in range of (self) and network rendering stops
public event Action<mUDPClient> onUserDisconnected;
public void InvokeOnUserDisconnected(mUDPClient DisconnectedUser){
onUserDisconnected?.Invoke(DisconnectedUser);
public void InvokeOnUserDisconnected(mUDPClient User){
onUserDisconnected?.Invoke(User);
}
// When any user disconnects from the server that isn't (self)
public event Action<string> onUserLeft;
public void InvokeOnUserLeft(string UserName){
onUserLeft?.Invoke(UserName);
public event Action<mUDPClient> onUserLeft;
public void InvokeOnUserLeft(mUDPClient User){
onUserLeft?.Invoke(User);
}
// When (self) disconnects to the server