Example #1
0
 /// <summary>
 /// Equalses the specified client.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <returns></returns>
 public bool Equals(SignalRWebClient client)
 {
     if (client == null)
     {
         return(false);
     }
     return(this.UserName.Equals(client.UserName));
 }
Example #2
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Execute(string command)
        {
            string id = Context.ConnectionId;

            SignalRWebClient sender = container.GetClientByID(id);

            if (sender == null)
            {
                return;
            }

            CommandResult res = controller.ExecuteCommand(command, sender);

            SendResult(sender, res);
        }
Example #3
0
        /// <summary>
        /// Notifies the client.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <param name="n">The n.</param>
        public void NotifyClient(IClient c, Notification n)
        {
            SignalRWebClient client = c as SignalRWebClient;

            switch (n.NotificationType)
            {
            case Notification.Type.GameStarted:
                //Maze maze = Maze.FromJSON(n.Data);
                Clients.Client(client.ID).GameStarted(n.Data);
                break;

            case Notification.Type.GameOver:
                // n.data is message from the server.
                // if the message contains the keyword Win, then its the winning player.
                // i know, this is a dirty workaround, but it works and im too busy
                // to rewrite it.
                if (n.Data.Contains("Win"))
                {
                    PlayerController.AddWin(client.UserName);
                }
                else if (n.Data.Contains("Lost"))
                {
                    PlayerController.AddLoss(client.UserName);
                }
                Clients.Client(client.ID).GameOver(n.Data);
                break;

            case Notification.Type.PlayerMoved:
                //MoveUpdate mu = MoveUpdate.FromJSON(n.Data);
                Clients.Client(client.ID).PlayerMoved(n.Data);
                break;

            default:
                break;
            }
        }
Example #4
0
 /// <summary>
 /// Sends the result.
 /// </summary>
 /// <param name="c">The c.</param>
 /// <param name="res">The resource.</param>
 private void SendResult(SignalRWebClient c, CommandResult res)
 {
     Clients.Client(c.ID).CommandResult(res.ToJSON());
 }