From b42a2f9728fd713f099419d8004219c6d49c4422 Mon Sep 17 00:00:00 2001 From: Patrick Hellebrand Date: Wed, 22 Sep 2021 15:50:19 +0200 Subject: [PATCH] Fixed json formatting in SendMessage --- PolyChat/Controller.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/PolyChat/Controller.cs b/PolyChat/Controller.cs index 24687ae..1f202e3 100644 --- a/PolyChat/Controller.cs +++ b/PolyChat/Controller.cs @@ -42,7 +42,7 @@ namespace PolyChat private void Serve() { - Debug.WriteLine("! SERVER STARTING !"); + Debug.WriteLine("--- Controller.Serve ---"); SocketIOServer server = new SocketIOServer(new SocketIOServerOption( PORT )); @@ -69,9 +69,12 @@ namespace PolyChat { Debug.WriteLine("--- Controller.SendMessage ---"); Debug.WriteLine($"{type} -> {ip} content: {content}"); - string json = $"{{ type: {type}, content: {content} }}"; - Debug.WriteLine($"json: {json}"); - Connections[ip].SendMessage(json); + JObject json = new JObject( + new JProperty("type", type), + new JProperty("content", content) + ); + Debug.WriteLine($"json: {json.ToString()}"); + Connections[ip].SendMessage(json.ToString()); } private void OnMessage(string ip, JToken[] data)