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;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using SBRL.Utilities;
|
using SBRL.Utilities;
|
||||||
|
@ -22,6 +22,11 @@ namespace Nibriboard.Client.Messages
|
||||||
[JsonConverter(typeof(ToStringJsonConverter))]
|
[JsonConverter(typeof(ToStringJsonConverter))]
|
||||||
public ColourHSL Colour;
|
public ColourHSL Colour;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of planes that this nibriboard server currently has.
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Planes;
|
||||||
|
|
||||||
public HandshakeResponseMessage()
|
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>
|
/// </summary>
|
||||||
public class NibriClient
|
public class NibriClient
|
||||||
{
|
{
|
||||||
|
#region Id Generation Logic
|
||||||
|
|
||||||
private static int nextId = 1;
|
private static int nextId = 1;
|
||||||
private static int getNextId() { return nextId++; }
|
private static int getNextId() { return nextId++; }
|
||||||
|
|
||||||
|
@ -30,10 +32,18 @@ namespace Nibriboard.Client
|
||||||
/// This client's unique id.
|
/// This client's unique id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly int Id = getNextId();
|
public readonly int Id = getNextId();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The nibri client manager
|
/// The nibri client manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly NibriClientManager manager;
|
private readonly NibriClientManager manager;
|
||||||
|
/// <summary>
|
||||||
|
/// The plane that this client is currently on.
|
||||||
|
/// </summary>
|
||||||
|
private Plane currentPlane;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The underlying websocket connection to the client.
|
/// The underlying websocket connection to the client.
|
||||||
/// Please try not to call the send method on here - use the NibriClient Send() method instead.
|
/// Please try not to call the send method on here - use the NibriClient Send() method instead.
|
||||||
|
@ -153,6 +163,8 @@ namespace Nibriboard.Client
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Message Sending
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a <see cref="Nibriboard.Client.Messages.Message"/> to the client.
|
/// 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.
|
/// 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());
|
Send(new HeartbeatMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Closes the connection to the client gracefully.
|
/// Closes the connection to the client gracefully.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -219,7 +233,7 @@ namespace Nibriboard.Client
|
||||||
/// <returns>Whether this client can see the chunk located at the specified chunk reference</returns>
|
/// <returns>Whether this client can see the chunk located at the specified chunk reference</returns>
|
||||||
public bool CanSee(ChunkReference chunkRef)
|
public bool CanSee(ChunkReference chunkRef)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Message Handlers
|
#region Message Handlers
|
||||||
|
@ -240,6 +254,9 @@ namespace Nibriboard.Client
|
||||||
HandshakeResponseMessage handshakeResponse = new HandshakeResponseMessage();
|
HandshakeResponseMessage handshakeResponse = new HandshakeResponseMessage();
|
||||||
handshakeResponse.Id = Id;
|
handshakeResponse.Id = Id;
|
||||||
handshakeResponse.Colour = Colour;
|
handshakeResponse.Colour = Colour;
|
||||||
|
foreach(Plane plane in manager.SpaceManager.Planes)
|
||||||
|
handshakeResponse.Planes.Add(plane.Name);
|
||||||
|
|
||||||
Send(handshakeResponse);
|
Send(handshakeResponse);
|
||||||
|
|
||||||
// Tell the new client about everyone else who's connected
|
// Tell the new client about everyone else who's connected
|
||||||
|
|
|
@ -21,7 +21,11 @@
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<CustomCommands>
|
<CustomCommands>
|
||||||
<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>
|
||||||
</CustomCommands>
|
</CustomCommands>
|
||||||
<Externalconsole>true</Externalconsole>
|
<Externalconsole>true</Externalconsole>
|
||||||
|
@ -86,6 +90,7 @@
|
||||||
<Compile Include="Client\Messages\IdleDisconnectMessage.cs" />
|
<Compile Include="Client\Messages\IdleDisconnectMessage.cs" />
|
||||||
<Compile Include="Client\Messages\HeartbeatMessage.cs" />
|
<Compile Include="Client\Messages\HeartbeatMessage.cs" />
|
||||||
<Compile Include="Client\Messages\ChunkUpdateMessage.cs" />
|
<Compile Include="Client\Messages\ChunkUpdateMessage.cs" />
|
||||||
|
<Compile Include="Client\Messages\PlaneChangeMessage.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="ClientFiles\index.html" />
|
<EmbeddedResource Include="ClientFiles\index.html" />
|
||||||
|
|
Loading…
Reference in a new issue