public void object_added(IFireObject fireObject) { Debug.Print("Object added : " + fireObject.Revision); if (fireObject.Path == "GameCommand") { GameCommand cmdReceived = (GameCommand)this.fdCommands.Items.Where(c => c.Id == fireObject.Id).FirstOrDefault(); try { if (cmdReceived == null) { new CommandFeedback(cmdReceived, enCommandStatus.Rejected, "Command not found").Save(this.FAppPrivate); } else { Player player = this.fdPlayers.TypedItems <Player>().Where(c => c.UserId == cmdReceived.UserId).FirstOrDefault(); if (player == null) { new CommandFeedback(cmdReceived, enCommandStatus.Rejected, "Player not found").Save(this.FAppPrivate); } else { PlayerGame playerGame = this.flPlayerGames.TypedItems <PlayerGame>().Where(c => c.UserId == cmdReceived.UserId).FirstOrDefault(); string gameId; if (playerGame != null) { gameId = playerGame.GameId; } else { gameId = cmdReceived.ObjectId; } Game game = this.fdGames.TypedItems <Game>().Where(c => c.Id == gameId).FirstOrDefault(); switch (cmdReceived.Command) { case enCommand.JoinGame: JoinGame(cmdReceived, player, playerGame, game); break; case enCommand.LeaveGame: LeaveGame(cmdReceived, playerGame, game); break; case enCommand.AddUnit: AddUnit(cmdReceived, playerGame, game); break; case enCommand.MoveForward: MoveUnit(cmdReceived, playerGame, game); break; case enCommand.MoveBackward: cmdReceived.Distance = -cmdReceived.Distance; MoveUnit(cmdReceived, playerGame, game); break; case enCommand.RotateCCW: //per 45 graden RotateUnit(cmdReceived, playerGame, game); break; case enCommand.RotateCW: RotateUnit(cmdReceived, playerGame, game); break; case enCommand.FireFixedGun: FireFixedGun(cmdReceived, playerGame, game); break; case enCommand.RotateTurretCCW: break; case enCommand.RotateTurretCW: break; default: new CommandFeedback(cmdReceived, enCommandStatus.Rejected, "Unknown command").Save(this.FAppPrivate); break; } } } cmdReceived.Delete(this.FAppPrivate); } catch (Exception e) { new CommandFeedback(cmdReceived, enCommandStatus.Rejected, "Error: " + e.InnerException.Message).Save(this.FAppPrivate); cmdReceived.Delete(this.FAppPrivate); //throw; } } }