Fixed json formatting in SendMessage

This commit is contained in:
Patrick Hellebrand
2021-09-22 15:50:19 +02:00
committed by Felix Hartmann (PEA3-Fe-FI)
parent 05e3e9e0c4
commit b42a2f9728

View File

@@ -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)