diff --git a/Client/Client.cs b/Client/Client.cs index 17551de..5152afe 100644 --- a/Client/Client.cs +++ b/Client/Client.cs @@ -72,10 +72,10 @@ namespace Client Array.Copy(message, 1, payload, 0, message.Length - 1); switch (id) { - case 0x01: + case JSONConvert.LOGIN: // json log in username data break; - case 0x02: + case JSONConvert.MESSAGE: // json message data (string, string) combo = JSONConvert.GetUsernameAndMessage(payload); string textUsername = combo.Item1; @@ -84,11 +84,11 @@ namespace Client break; - case 0x03: + case JSONConvert.LOBBY: // lobby data //TODO fill lobby with the data received break; - case 0x04: + case JSONConvert.CANVAS: // canvas data break; default: diff --git a/Server/Models/ServerClient.cs b/Server/Models/ServerClient.cs index b82e4f4..7544baf 100644 --- a/Server/Models/ServerClient.cs +++ b/Server/Models/ServerClient.cs @@ -91,7 +91,7 @@ namespace Server.Models switch(id) { - case 0x01: + case JSONConvert.LOGIN: // json log in username data string uName = JSONConvert.GetUsernameLogin(message); if (uName != null) @@ -102,7 +102,7 @@ namespace Server.Models } break; - case 0x02: + case JSONConvert.MESSAGE: // json message data (string, string) combo = JSONConvert.GetUsernameAndMessage(payload); string textUsername = combo.Item1; @@ -111,10 +111,10 @@ namespace Server.Models // todo handle sending to all except this user the username and message to display in chat break; - case 0x03: + case JSONConvert.LOBBY: // lobby data break; - case 0x04: + case JSONConvert.CANVAS: // canvas data // todo send canvas data to all other serverclients in lobby break; diff --git a/SharedClientServer/JSONConvert.cs b/SharedClientServer/JSONConvert.cs index 1eb5c04..de853eb 100644 --- a/SharedClientServer/JSONConvert.cs +++ b/SharedClientServer/JSONConvert.cs @@ -7,6 +7,10 @@ namespace SharedClientServer { class JSONConvert { + public const byte LOGIN = 0x01; + public const byte MESSAGE = 0x02; + public const byte LOBBY = 0x03; + public const byte CANVAS = 0x04; public static (string,string) GetUsernameAndMessage(byte[] json) { string msg = Encoding.ASCII.GetString(json); @@ -21,6 +25,11 @@ namespace SharedClientServer return payload.username; } + public static byte[] GetUsernameMessage(string username) + { + + } + /// /// constructs a message that can be sent to the clients or server ///