public static Message getMessageJoinRoom(short roomId)
 {
     byte[] data = BitConverterMapping.GetBytes(roomId);
     return(new Message()
     {
         Command = MessageCode.JOIN_ROOM_CODE,
         Data = data,
     });
 }
    public static Message registerPlayer(String username)
    {
        byte[] data1     = Encoding.UTF8.GetBytes(username);
        byte[] dataSize1 = BitConverterMapping.GetBytes((short)username.Length);

        byte[] data = new byte[data1.Length + dataSize1.Length];
        dataSize1.CopyTo(data, 0);
        data1.CopyTo(data, dataSize1.Length);
        return(new Message()
        {
            Command = MessageCode.REGISTER_PLAYER,
            Data = data,
        });
    }
    public static Message getMessageChangePosition(byte direction, Vector3 position)
    {
        byte[] dataX = BitConverterMapping.GetBytes(position.x);
        byte[] dataY = BitConverterMapping.GetBytes(position.y);

        byte[] data = new byte[1 + dataX.Length + dataY.Length];
        data[0] = direction;
        dataX.CopyTo(data, 1);
        dataY.CopyTo(data, 1 + dataX.Length);

        return(new Message()
        {
            Command = MessageCode.CHANGE_POSITION_CODE,
            Data = data,
        });
    }