1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

[server] Add listing currently connected clients to CLI

This commit is contained in:
Starbeamrainbowlabs 2017-12-16 12:16:43 +00:00
parent 4397d90fe9
commit 23fb5c5b33
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 32 additions and 8 deletions

View file

@ -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;
}
}
/// <summary>
/// Fires when this nibri client disconnects.
/// </summary>

View file

@ -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.");

View file

@ -18,15 +18,16 @@ namespace Nibriboard
/// </summary>
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();

View file

@ -174,6 +174,11 @@ namespace SBRL.Utilities
return result;
}
public override string ToString()
{
return string.Format($"{Width}x{Height} @ ({X}, {Y})");
}
}
}