示例#1
0
 private async Task AnalyzeCommandBagAsync(dynamic currentCommand, JsonReceivedEventArgs args)
 {
     if (SimilarCommandsByDifferentSenders(currentCommand))
     {
         await Task.Run(() => OnArrivedToEvent?.Invoke(this, args));
     }
 }
示例#2
0
        public async Task HandleJsonMessage(Room room, dynamic jsonObj)
        {
            JsonReceivedEventArgs args = new JsonReceivedEventArgs(room, jsonObj);

            if (jsonObj.command == Constants.JsonCommands.ClientCommands.POWER_UP)
            {
                await Task.Run(() => OnPowerUpEvent?.Invoke(this, args));

                return;
            }

            if (jsonObj.command == Constants.JsonCommands.ClientCommands.MOVE_TO)
            {
                await Task.Run(() => OnMoveToEvent?.Invoke(this, args));

                return;
            }

            if (jsonObj.command == Constants.JsonCommands.ClientCommands.UPGRADE_TOWER)
            {
                await Task.Run(() => UpgradeTowerEvent?.Invoke(this, args));

                return;
            }

            if (jsonObj.command == Constants.JsonCommands.ClientCommands.ARRIVED_TO)
            {
                await AnalyzeCommandBagAsync(jsonObj, args);
            }
        }
        public override async Task Handle(Room room, dynamic jsonObj)
        {
            JsonReceivedEventArgs args = new JsonReceivedEventArgs(room, jsonObj);

            if (jsonObj.command == Constants.JsonCommands.ClientCommands.UPGRADE_TOWER)
            {
                await Task.Run(() => UpgradeTowerEvent?.Invoke(this, args));
            }
            else
            {
                await base.Handle((Room)room, (object)jsonObj);
            }
        }
示例#4
0
        public override async Task Handle(Room room, dynamic jsonObj)
        {
            JsonReceivedEventArgs args = new JsonReceivedEventArgs(room, jsonObj);

            if (jsonObj.command == Constants.JsonCommands.ClientCommands.ARRIVED_TO)
            {
                await AnalyzeCommandBagAsync(jsonObj, args);
            }
            else
            {
                await base.Handle((Room)room, (object)jsonObj);
            }
        }