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

Start building message classes and deserialising incoming messages into them

This commit is contained in:
Starbeamrainbowlabs 2017-01-27 21:24:58 +00:00
parent 96c6c8e565
commit abbcb7a8c8
5 changed files with 20 additions and 5 deletions

View file

@ -3,7 +3,7 @@ using System.IO;
using IotWeb.Common.Http;
using MimeSharp;
using SBRLUtilities;
using SBRL.Utilities;
using System.Collections.Generic;
using System.Reflection;

View file

@ -1,8 +1,10 @@
using System;
using System.Threading.Tasks;
using System.Text;
using System.Collections.Generic;
using IotWeb.Common.Http;
using SBRL.Utilities;
namespace Nibriboard.Client
{
@ -11,6 +13,11 @@ namespace Nibriboard.Client
private readonly NibriClientManager manager;
private readonly WebSocket client;
private Dictionary<string, Type> messageEventTypes = new Dictionary<string, Type>()
{
};
public NibriClient(NibriClientManager inManager, WebSocket inClient)
{
manager = inManager;
@ -19,7 +26,7 @@ namespace Nibriboard.Client
client.DataReceived += async (WebSocket clientSocket, string frame) => {
try
{
await onMessage(frame);
await handleMessage(frame);
}
catch (Exception error)
{
@ -38,8 +45,10 @@ namespace Nibriboard.Client
client.Send(Encoding.UTF8.GetBytes(message));
}
private async Task onMessage(string frame)
private async Task handleMessage(string frame)
{
string eventName = JsonUtilities.DeserializeProperty(frame, "event");
}
}

View file

@ -48,6 +48,7 @@
<Reference Include="MimeSharp">
<HintPath>..\packages\MimeSharp.1.0.0\lib\MimeSharp.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
@ -69,6 +70,10 @@
<Compile Include="Client\NibriClientManager.cs" />
<Compile Include="Client\ClientSettings.cs" />
<Compile Include="Client\HttpClientSettingsHandler.cs" />
<Compile Include="Utilities\PointExtensions.cs" />
<Compile Include="Utilities\JsonUtilities.cs" />
<Compile Include="Client\Messages\Message.cs" />
<Compile Include="Client\Messages\HandshakeRequestMessage.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ClientFiles\index.html" />
@ -81,6 +86,7 @@
<Folder Include="Utilities\" />
<Folder Include="ClientFiles\" />
<Folder Include="Client\" />
<Folder Include="Client\Messages\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View file

@ -1,7 +1,7 @@
using System;
using System.Reflection;
using System.Threading.Tasks;
using SBRLUtilities;
using SBRL.Utilities;
namespace Nibriboard
{

View file

@ -5,7 +5,7 @@ using System.Net.Configuration;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace SBRLUtilities
namespace SBRL.Utilities
{
/// <summary>
/// A collection of static methods for manipulating embedded resources.