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); } }
private async void HandleUpgradeEvent(object sender, JsonReceivedEventArgs args) { IGameStateExecutable executive = new UpgradeTowerExecutive(); await ExecuteCommandAndNotifyClients(executive, args); }