/// <summary>
        /// Proxy function that creates the game object server side.
        /// </summary>
        /// <param name="gameId"></param>
        /// <returns>Return the games password to display to the viewers.</returns>
        public async Task <string> InitGame(string gameId)
        {
            ServerGameSession game = MvcApplication.Manager.FindSession(gameId);

            if (game != null)
            {
                if (string.IsNullOrEmpty(game.GameConnectionId) && !game.GameStarted)
                {
                    game.GameConnectionId = Context.ConnectionId;
                    await Clients.Caller.setGameMode("AWAITING_PLAYERS");

                    if (game.game.Players.Count == 0)
                    {
                        game.game.CreateNewPlayerObjects();
                    }
                    else
                    {
                        if (game.game.HasConnectedPlayers())
                        {
                            await Clients.Caller.setGameMode("AWAITING_PLAYERS_REFRESHED");

                            await game.UpdateHost();
                        }
                    }
                }
                else if (string.IsNullOrEmpty(game.GameConnectionId) && game.GameStarted)
                {
                    game.GameConnectionId = Context.ConnectionId;
                    await Clients.Caller.setGameMode("RESUMING_GAME");

                    await game.UpdateHost();

                    PlayerObject pObject = game.game.Players.FirstOrDefault(n => n.id == game.game.CurrentPlayer);
                    await game.UpdateCurrentPlayingName(pObject);

                    await Clients.Caller.displayMessage($"Game is resuming");
                }
                else
                {
                    Clients.Caller.endSession("game is already being hosted somewhere else.");
                    return(null);
                }

                return(game.GamePassword);
            }
            else
            {
                Clients.Caller.endSession("unkown game id was passed to the server.");
            }
            return(null);
        }
        /// <summary>
        /// Proxy funtion that causes an update on all connected screens.
        /// </summary>
        /// <returns></returns>
        public async Task Update()
        {
            ServerGameSession game = MvcApplication.Manager.FindSessionByConnectionId(Context.ConnectionId);

            if (game != null)
            {
                await game.UpdateAll();

                PlayerObject pObject = game.game.Players.FirstOrDefault(n => n.id == game.game.CurrentPlayer);
                await game.UpdateCurrentPlayingName(pObject);
            }
            else
            {
                Clients.Caller.endSession("unkown game id was passed to the server.");
            }
        }
        /// <summary>
        /// Proxy function that starts the game
        /// </summary>
        /// <returns></returns>
        public async Task StartGame()
        {
            ServerGameSession game = MvcApplication.Manager.FindSessionByConnectionId(Context.ConnectionId);

            if (game != null)
            {
                game.GameStarted = true;

                //remove the empty player objects: no need for new players to connect after the game has started
                game.game.Players.RemoveAll(n => n.connid == "");
                await Clients.Caller.startGame(game.game.Players);

                await Clients.Caller.displayMessage($"Game has started");

                await game.UpdateCurrentPlayingName(game.game.Players[0]);
            }
            else
            {
                await Clients.Caller.endSession("unkown game id was passed to the server.");
            }
        }