Exemple #1
0
        /// <summary>
        /// Joins the game.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="username">The username.</param>
        public void JoinGame(string name, string username)
        {
            string rival       = gameGenerator[name];
            string recipientId = connectedUsers[username];

            if (recipientId == null)
            {
                return;
            }
            string otherRecipientId = connectedUsers[rival];

            if (recipientId == null)
            {
                return;
            }
            Maze    maze = model.GetGames(name);
            JObject obj  = JObject.Parse(maze.ToJSON());

            Clients.Client(otherRecipientId).gotMaze(obj, username);
            Clients.Client(recipientId).gotMaze(obj, rival);
            games.Remove(name);
            model.DeleteGame(name);
            SendGames();
            Clients.Client(otherRecipientId).start(username);
            Clients.Client(recipientId).start(rival);
        }
Exemple #2
0
 // GET: api/Multi/5
 /// <summary>
 /// Gets the specified game.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <returns>JObject.</returns>
 public JObject Get(string game)
 {
     return(JObject.Parse(singleModel.GetGames(game).ToJSON()));
 }