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

Add references to the ripple space manager to allow the nibri clients to interact with it.

This commit is contained in:
Starbeamrainbowlabs 2017-03-04 19:59:22 +00:00
parent 8572ed6d52
commit f3c2806243
3 changed files with 33 additions and 3 deletions

View file

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Nibriboard.Client.Messages; using Nibriboard.Client.Messages;
using System.Threading; using System.Threading;
using Nibriboard.RippleSpace;
namespace Nibriboard.Client namespace Nibriboard.Client
{ {
@ -13,6 +14,11 @@ namespace Nibriboard.Client
/// </summary> /// </summary>
public class NibriClientManager : IWebSocketRequestHandler public class NibriClientManager : IWebSocketRequestHandler
{ {
/// <summary>
/// The ripple space manager that this client manager is connected to.
/// </summary>
public RippleSpaceManager SpaceManager;
private ClientSettings clientSettings; private ClientSettings clientSettings;
public List<NibriClient> Clients = new List<NibriClient>(); public List<NibriClient> Clients = new List<NibriClient>();
@ -35,10 +41,12 @@ namespace Nibriboard.Client
} }
} }
public NibriClientManager(ClientSettings inClientSettings, CancellationToken inCancellationToken) public NibriClientManager(ClientSettings inClientSettings, RippleSpaceManager inSpaceManager, CancellationToken inCancellationToken)
{ {
clientSettings = inClientSettings; clientSettings = inClientSettings;
canceller = inCancellationToken; canceller = inCancellationToken;
spaceManager = inSpaceManager;
} }
/// <summary> /// <summary>

View file

@ -22,6 +22,7 @@ namespace Nibriboard
private RippleSpaceManager planeManager = new RippleSpaceManager(); private RippleSpaceManager planeManager = new RippleSpaceManager();
private readonly CancellationTokenSource clientManagerCanceller = new CancellationTokenSource(); private readonly CancellationTokenSource clientManagerCanceller = new CancellationTokenSource();
private NibriClientManager clientManager;
public readonly int Port = 31586; public readonly int Port = 31586;
@ -52,9 +53,15 @@ namespace Nibriboard
); );
// Websocket setup // Websocket setup
clientManager = new NibriClientManager(
clientSettings,
clientManagerCanceller.Token
);
httpServer.AddWebSocketRequestHandler( httpServer.AddWebSocketRequestHandler(
clientSettings.WebsocketPath, clientSettings.WebsocketPath,
new NibriClientManager(clientSettings, clientManagerCanceller.Token)
clientManager
); );
} }

View file

@ -27,7 +27,22 @@ namespace Nibriboard.RippleSpace
Log.WriteLine("[RippleSpace] New blank ripplespace initialised."); Log.WriteLine("[RippleSpace] New blank ripplespace initialised.");
} }
public Plane GetById(string targetName) /// <summary>
/// Gets the plane with the specified name from this RippleSpace.
/// </summary>
/// <param name="planeName">The plane name to retrieve.</param>
public Plane this[string planeName] {
get {
return GetById(planeName);
}
}
/// <summary>
/// Gets the plane with the specified name from this RippleSpace.
/// </summary>
/// <param name="targetName">The plane name to retrieve.</param>
/// <returns>The plane wwith the specified name.</returns>
protected Plane GetById(string targetName)
{ {
foreach (Plane plane in Planes) foreach (Plane plane in Planes)
{ {