Merge branch 'develop' into client

This commit is contained in:
shinichi
2020-09-23 12:01:16 +02:00
6 changed files with 90 additions and 2 deletions

View File

@@ -1,8 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Message\Message.csproj" />
</ItemGroup>
</Project> </Project>

63
Message/Message.cs Normal file
View File

@@ -0,0 +1,63 @@
using Newtonsoft.Json;
using System;
namespace Message
{
/// <summary>
/// Message class to handle traffic between clients and server
/// </summary>
public class Message
{
/// <summary>
/// identifier for the message
/// </summary>
public Identifier Identifier
{
get;set;
}
/// <summary>
/// payload of the message, the actual text
/// </summary>
public string Payload
{
get;set;
}
/// <summary>
/// constructs a new message with the given parameters
/// </summary>
/// <param name="identifier">the identifier</param>
/// <param name="payload">the payload</param>
public Message(Identifier identifier, string payload)
{
this.Identifier = identifier;
this.Payload = payload;
}
/// <summary>
/// serializes this object to a JSON string
/// </summary>
/// <returns>a JSON representation of this object</returns>
public string Serialize()
{
return JsonConvert.SerializeObject(this);
}
/// <summary>
/// deserializes a JSON string into a new Message object
/// </summary>
/// <param name="json">the JSON string to deserialize</param>
/// <returns>a new <c>Message</c> object from the JSON string</returns>
public static Message Deserialize(string json)
{
return (Message)JsonConvert.DeserializeObject(json);
}
}
public enum Identifier
{
LOGIN,
CHAT,
}
}

12
Message/Message.csproj Normal file
View File

@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
</Project>

View File

@@ -24,7 +24,6 @@ namespace Hardware
public BLEHandler(IDataConverter dataConverter) public BLEHandler(IDataConverter dataConverter)
{ {
this.dataConverter = dataConverter; this.dataConverter = dataConverter;
bool running = false;
} }
/// <summary> /// <summary>

View File

@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "..\Server\Server.
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "..\Client\Client.csproj", "{5759DD20-7A4F-4D8D-B986-A70A7818C112}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "..\Client\Client.csproj", "{5759DD20-7A4F-4D8D-B986-A70A7818C112}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Message", "..\Message\Message.csproj", "{9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
{5759DD20-7A4F-4D8D-B986-A70A7818C112}.Debug|Any CPU.Build.0 = Debug|Any CPU {5759DD20-7A4F-4D8D-B986-A70A7818C112}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5759DD20-7A4F-4D8D-B986-A70A7818C112}.Release|Any CPU.ActiveCfg = Release|Any CPU {5759DD20-7A4F-4D8D-B986-A70A7818C112}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5759DD20-7A4F-4D8D-B986-A70A7818C112}.Release|Any CPU.Build.0 = Release|Any CPU {5759DD20-7A4F-4D8D-B986-A70A7818C112}.Release|Any CPU.Build.0 = Release|Any CPU
{9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -5,4 +5,8 @@
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Message\Message.csproj" />
</ItemGroup>
</Project> </Project>