mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[server] Fill out more nibri client <--> plane interaction logic
This commit is contained in:
parent
c559e6eaef
commit
d846d335b1
4 changed files with 43 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using SBRL.Utilities;
|
||||
|
@ -22,6 +22,11 @@ namespace Nibriboard.Client.Messages
|
|||
[JsonConverter(typeof(ToStringJsonConverter))]
|
||||
public ColourHSL Colour;
|
||||
|
||||
/// <summary>
|
||||
/// A list of planes that this nibriboard server currently has.
|
||||
/// </summary>
|
||||
public List<string> Planes;
|
||||
|
||||
public HandshakeResponseMessage()
|
||||
{
|
||||
}
|
||||
|
|
13
Nibriboard/Client/Messages/PlaneChangeMessage.cs
Normal file
13
Nibriboard/Client/Messages/PlaneChangeMessage.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
namespace Nibriboard.Client.Messages
|
||||
{
|
||||
public class PlaneChangeMessage : Message
|
||||
{
|
||||
public string NewPlaneName;
|
||||
|
||||
public PlaneChangeMessage(string inNewPlaneName)
|
||||
{
|
||||
NewPlaneName = inNewPlaneName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,6 +23,8 @@ namespace Nibriboard.Client
|
|||
/// </summary>
|
||||
public class NibriClient
|
||||
{
|
||||
#region Id Generation Logic
|
||||
|
||||
private static int nextId = 1;
|
||||
private static int getNextId() { return nextId++; }
|
||||
|
||||
|
@ -30,10 +32,18 @@ namespace Nibriboard.Client
|
|||
/// This client's unique id.
|
||||
/// </summary>
|
||||
public readonly int Id = getNextId();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The nibri client manager
|
||||
/// </summary>
|
||||
private readonly NibriClientManager manager;
|
||||
/// <summary>
|
||||
/// The plane that this client is currently on.
|
||||
/// </summary>
|
||||
private Plane currentPlane;
|
||||
|
||||
/// <summary>
|
||||
/// The underlying websocket connection to the client.
|
||||
/// Please try not to call the send method on here - use the NibriClient Send() method instead.
|
||||
|
@ -153,6 +163,8 @@ namespace Nibriboard.Client
|
|||
|
||||
#endregion
|
||||
|
||||
#region Message Sending
|
||||
|
||||
/// <summary>
|
||||
/// Sends a <see cref="Nibriboard.Client.Messages.Message"/> to the client.
|
||||
/// If you *really* need to send a raw message to the client, you can do so with the SendRawa() method.
|
||||
|
@ -183,6 +195,8 @@ namespace Nibriboard.Client
|
|||
Send(new HeartbeatMessage());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Closes the connection to the client gracefully.
|
||||
/// </summary>
|
||||
|
@ -219,7 +233,7 @@ namespace Nibriboard.Client
|
|||
/// <returns>Whether this client can see the chunk located at the specified chunk reference</returns>
|
||||
public bool CanSee(ChunkReference chunkRef)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
#region Message Handlers
|
||||
|
@ -240,6 +254,9 @@ namespace Nibriboard.Client
|
|||
HandshakeResponseMessage handshakeResponse = new HandshakeResponseMessage();
|
||||
handshakeResponse.Id = Id;
|
||||
handshakeResponse.Colour = Colour;
|
||||
foreach(Plane plane in manager.SpaceManager.Planes)
|
||||
handshakeResponse.Planes.Add(plane.Name);
|
||||
|
||||
Send(handshakeResponse);
|
||||
|
||||
// Tell the new client about everyone else who's connected
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CustomCommands>
|
||||
<CustomCommands>
|
||||
<Command type="BeforeBuild" command="npm run build" workingdir="${ProjectDir}/ClientFiles" />
|
||||
<Command>
|
||||
<type>BeforeBuild</type>
|
||||
<command>npm run build</command>
|
||||
<workingdir>${ProjectDir}/ClientFiles</workingdir>
|
||||
</Command>
|
||||
</CustomCommands>
|
||||
</CustomCommands>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
|
@ -86,6 +90,7 @@
|
|||
<Compile Include="Client\Messages\IdleDisconnectMessage.cs" />
|
||||
<Compile Include="Client\Messages\HeartbeatMessage.cs" />
|
||||
<Compile Include="Client\Messages\ChunkUpdateMessage.cs" />
|
||||
<Compile Include="Client\Messages\PlaneChangeMessage.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ClientFiles\index.html" />
|
||||
|
|
Loading…
Reference in a new issue