[ADDED] Color can now we transfered, still need to get fixed with the buffer -_-
This commit is contained in:
@@ -6,7 +6,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SharedClientServer
|
||||
{
|
||||
class JSONConvert
|
||||
@@ -26,6 +27,13 @@ namespace SharedClientServer
|
||||
LIST,
|
||||
REQUEST
|
||||
}
|
||||
|
||||
public enum CanvasInfo
|
||||
{
|
||||
DRAWING,
|
||||
RESET
|
||||
}
|
||||
|
||||
public static (string,string) GetUsernameAndMessage(byte[] json)
|
||||
{
|
||||
string msg = Encoding.ASCII.GetString(json);
|
||||
@@ -149,24 +157,40 @@ namespace SharedClientServer
|
||||
|
||||
#endregion
|
||||
|
||||
public static byte[] ConstructCanvasDataSend(double[] coordinates)
|
||||
public static byte[] ConstructCanvasDataSend(CanvasInfo typeToSend, double[] coordinates, Color colorToSend)
|
||||
{
|
||||
return GetMessageToSend(CANVAS, new
|
||||
{
|
||||
coordinatesLine = coordinates
|
||||
});
|
||||
type = typeToSend,
|
||||
coordinatesLine = coordinates,
|
||||
color = colorToSend
|
||||
}); ;
|
||||
}
|
||||
|
||||
public static CanvasInfo GetCanvasMessageType(byte[] payload)
|
||||
{
|
||||
dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(payload));
|
||||
CanvasInfo type = json.type;
|
||||
return type;
|
||||
}
|
||||
|
||||
public static double[] getCoordinates(byte[] payload)
|
||||
{
|
||||
dynamic payloadD = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(payload));
|
||||
JArray coordinatesArray = payloadD.coordinatesLine;
|
||||
dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(payload));
|
||||
JArray coordinatesArray = json.coordinatesLine;
|
||||
|
||||
double[] coordinates = coordinatesArray.ToObject<double[]>();
|
||||
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
public static Color getCanvasDrawingColor(byte[] payload)
|
||||
{
|
||||
dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(payload));
|
||||
Color color = json.color;
|
||||
return color;
|
||||
}
|
||||
|
||||
public static byte[] ConstructGameStartData(int lobbyID)
|
||||
{
|
||||
string startGame = "startGame";
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Client
|
||||
private int _id;
|
||||
private int _playersIn;
|
||||
private int _maxPlayers;
|
||||
private bool _lobbyJoineble;
|
||||
private bool _lobbyJoinable;
|
||||
//private List<string> _usernames;
|
||||
private List<User> _users;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Client
|
||||
_maxPlayers = maxPlayers;
|
||||
//_usernames = new List<string>();
|
||||
_users = new List<User>();
|
||||
_lobbyJoineble = true;
|
||||
_lobbyJoinable = true;
|
||||
}
|
||||
|
||||
public void AddUser(string username, out bool succes)
|
||||
@@ -89,10 +89,10 @@ namespace Client
|
||||
set { _users = value; }
|
||||
}
|
||||
|
||||
public bool LobbyJoineble
|
||||
public bool LobbyJoinable
|
||||
{
|
||||
get { return _lobbyJoineble; }
|
||||
set { _lobbyJoineble = value; }
|
||||
get { return _lobbyJoinable; }
|
||||
set { _lobbyJoinable = value; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user