diff --git a/Nibriboard/Client/NibriClient.cs b/Nibriboard/Client/NibriClient.cs index f442166..e2b8d2e 100644 --- a/Nibriboard/Client/NibriClient.cs +++ b/Nibriboard/Client/NibriClient.cs @@ -10,6 +10,7 @@ using Nibriboard.Client.Messages; using Nibriboard.RippleSpace; using SBRL.GlidingSquirrel.Websocket; +using System.Net; namespace Nibriboard.Client { @@ -70,6 +71,11 @@ namespace Nibriboard.Client return !connection.IsClosing; } } + public IPEndPoint RemoteEndpoint { + get { + return connection.RemoteEndpoint; + } + } /// /// Fires when this nibri client disconnects. /// diff --git a/Nibriboard/CommandConsole.cs b/Nibriboard/CommandConsole.cs index ca61324..3135618 100644 --- a/Nibriboard/CommandConsole.cs +++ b/Nibriboard/CommandConsole.cs @@ -3,6 +3,7 @@ using System.IO; using System.Net; using System.Net.Sockets; using System.Threading.Tasks; +using Nibriboard.Client; using Nibriboard.RippleSpace; namespace Nibriboard @@ -64,8 +65,9 @@ namespace Nibriboard await destination.WriteLineAsync(" help Show this message"); await destination.WriteLineAsync(" save Save the ripplespace to disk"); await destination.WriteLineAsync(" plane list List all the currently loaded planes"); - await destination.WriteLineAsync(" plane create {new-plane-name} [{chunkSize}] Create a new named plane, optionally with the specified chunk size."); - await destination.WriteLineAsync(" plane status {plane-name} Show the statistics of the current plane."); + await destination.WriteLineAsync(" plane create {new-plane-name} [{chunkSize}] Create a new named plane, optionally with the specified chunk size"); + await destination.WriteLineAsync(" plane status {plane-name} Show the statistics of the specified plane"); + await destination.WriteLineAsync(" clients List the currently connected clients"); break; case "save": await destination.WriteAsync("Saving ripple space - "); @@ -135,6 +137,16 @@ namespace Nibriboard } break; + case "clients": + + foreach(NibriClient client in server.AppServer.NibriClients) { + await destination.WriteLineAsync($"{client.Id}: {client.Name} from {client.RemoteEndpoint}, on {client.CurrentPlane.Name} looking at {client.CurrentViewPort}"); + } + await destination.WriteLineAsync(); + await destination.WriteLineAsync($"Total {server.AppServer.ClientCount} clients"); + + break; + /*case "chunk": if(commandParts.Length < 2) { await destination.WriteLineAsync("Error: No sub-action specified."); diff --git a/Nibriboard/NibriboardServer.cs b/Nibriboard/NibriboardServer.cs index 8b85b1e..339036f 100644 --- a/Nibriboard/NibriboardServer.cs +++ b/Nibriboard/NibriboardServer.cs @@ -18,15 +18,16 @@ namespace Nibriboard /// public class NibriboardServer { - private CommandConsole commandServer; - private NibriboardApp appServer; - private ClientSettings clientSettings; - public RippleSpaceManager PlaneManager; + + private CommandConsole commandServer; public readonly int CommandPort = 31587; public readonly int Port = 31586; + public RippleSpaceManager PlaneManager; + public NibriboardApp AppServer; + public NibriboardServer(string pathToRippleSpace, int inPort = 31586) { Port = inPort; @@ -50,7 +51,7 @@ namespace Nibriboard }; // HTTP Server setup - appServer = new NibriboardApp(new NibriboardAppStartInfo() { + AppServer = new NibriboardApp(new NibriboardAppStartInfo() { FilePrefix = "Nibriboard.obj.client_dist", ClientSettings = clientSettings, SpaceManager = PlaneManager @@ -62,7 +63,7 @@ namespace Nibriboard public async Task Start() { - await appServer.Start(); + await AppServer.Start(); Log.WriteLine("[NibriboardServer] Started on port {0}", Port); await PlaneManager.StartMaintenanceMonkey(); diff --git a/Nibriboard/Utilities/Rectangle.cs b/Nibriboard/Utilities/Rectangle.cs index 6329ee6..64adb20 100644 --- a/Nibriboard/Utilities/Rectangle.cs +++ b/Nibriboard/Utilities/Rectangle.cs @@ -174,6 +174,11 @@ namespace SBRL.Utilities return result; } + + public override string ToString() + { + return string.Format($"{Width}x{Height} @ ({X}, {Y})"); + } } }