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:
parent
96c6c8e565
commit
abbcb7a8c8
5 changed files with 20 additions and 5 deletions
|
@ -3,7 +3,7 @@ using System.IO;
|
||||||
using IotWeb.Common.Http;
|
using IotWeb.Common.Http;
|
||||||
using MimeSharp;
|
using MimeSharp;
|
||||||
|
|
||||||
using SBRLUtilities;
|
using SBRL.Utilities;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using IotWeb.Common.Http;
|
using IotWeb.Common.Http;
|
||||||
|
using SBRL.Utilities;
|
||||||
|
|
||||||
namespace Nibriboard.Client
|
namespace Nibriboard.Client
|
||||||
{
|
{
|
||||||
|
@ -11,6 +13,11 @@ namespace Nibriboard.Client
|
||||||
private readonly NibriClientManager manager;
|
private readonly NibriClientManager manager;
|
||||||
private readonly WebSocket client;
|
private readonly WebSocket client;
|
||||||
|
|
||||||
|
private Dictionary<string, Type> messageEventTypes = new Dictionary<string, Type>()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
public NibriClient(NibriClientManager inManager, WebSocket inClient)
|
public NibriClient(NibriClientManager inManager, WebSocket inClient)
|
||||||
{
|
{
|
||||||
manager = inManager;
|
manager = inManager;
|
||||||
|
@ -19,7 +26,7 @@ namespace Nibriboard.Client
|
||||||
client.DataReceived += async (WebSocket clientSocket, string frame) => {
|
client.DataReceived += async (WebSocket clientSocket, string frame) => {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await onMessage(frame);
|
await handleMessage(frame);
|
||||||
}
|
}
|
||||||
catch (Exception error)
|
catch (Exception error)
|
||||||
{
|
{
|
||||||
|
@ -38,8 +45,10 @@ namespace Nibriboard.Client
|
||||||
client.Send(Encoding.UTF8.GetBytes(message));
|
client.Send(Encoding.UTF8.GetBytes(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task onMessage(string frame)
|
private async Task handleMessage(string frame)
|
||||||
{
|
{
|
||||||
|
string eventName = JsonUtilities.DeserializeProperty(frame, "event");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
<Reference Include="MimeSharp">
|
<Reference Include="MimeSharp">
|
||||||
<HintPath>..\packages\MimeSharp.1.0.0\lib\MimeSharp.dll</HintPath>
|
<HintPath>..\packages\MimeSharp.1.0.0\lib\MimeSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
|
@ -69,6 +70,10 @@
|
||||||
<Compile Include="Client\NibriClientManager.cs" />
|
<Compile Include="Client\NibriClientManager.cs" />
|
||||||
<Compile Include="Client\ClientSettings.cs" />
|
<Compile Include="Client\ClientSettings.cs" />
|
||||||
<Compile Include="Client\HttpClientSettingsHandler.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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="ClientFiles\index.html" />
|
<EmbeddedResource Include="ClientFiles\index.html" />
|
||||||
|
@ -81,6 +86,7 @@
|
||||||
<Folder Include="Utilities\" />
|
<Folder Include="Utilities\" />
|
||||||
<Folder Include="ClientFiles\" />
|
<Folder Include="ClientFiles\" />
|
||||||
<Folder Include="Client\" />
|
<Folder Include="Client\" />
|
||||||
|
<Folder Include="Client\Messages\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SBRLUtilities;
|
using SBRL.Utilities;
|
||||||
|
|
||||||
namespace Nibriboard
|
namespace Nibriboard
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Net.Configuration;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SBRLUtilities
|
namespace SBRL.Utilities
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A collection of static methods for manipulating embedded resources.
|
/// A collection of static methods for manipulating embedded resources.
|
||||||
|
|
Loading…
Reference in a new issue