Ejemplo n.º 1
0
        private async Task ExecuteCommandAndNotifyClients(IGameStateExecutable executive, JsonReceivedEventArgs args)
        {
            try
            {
                string    roomId    = args.room.roomID;
                GameState gameState = roomIdToRoomsubjectDict[roomId].gameState;

                var   buffer = executive.ExecuteCommand(args, gameState); // Can throw exception
                await roomIdToRoomsubjectDict[roomId].Broadcast(buffer);
            }
            catch (Exception e)
            {
                string clientId = args.room.currentID;
                await FormatExceptionBufferAndSendToClient(e, clientId);
            }
        }
Ejemplo n.º 2
0
        private async void HandleUpgradeEvent(object sender, JsonReceivedEventArgs args)
        {
            IGameStateExecutable executive = new UpgradeTowerExecutive();

            await ExecuteCommandAndNotifyClients(executive, args);
        }