added template for receiving json chat message

This commit is contained in:
Sem van der Hoeven
2020-10-13 10:56:13 +02:00
parent 514460781b
commit 3dc641680d
5 changed files with 36 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedClientServer
{
class JSONConvert
{
public static (string,string) GetUsernameAndMessage(byte[] json)
{
string msg = Encoding.ASCII.GetString(json);
dynamic payload = JsonConvert.DeserializeObject(msg);
return (payload.username, payload.message);
}
}
}