added message class and added references to server and client projects
This commit is contained in:
12
Message/Message.csproj
Normal file
12
Message/Message.csproj
Normal 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>
|
||||
34
Message/Program.cs
Normal file
34
Message/Program.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace Message
|
||||
{
|
||||
public class Message
|
||||
{
|
||||
public string Identifier
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
|
||||
public string Payload
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
|
||||
public Message(string identifier, string payload)
|
||||
{
|
||||
this.Identifier = identifier;
|
||||
this.Payload = payload;
|
||||
}
|
||||
|
||||
public string Serialize()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
public static Message Deserialize(string json)
|
||||
{
|
||||
return (Message)JsonConvert.DeserializeObject(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user