Ejemplo n.º 1
0
        public async Task <string> InsertEngine(QuantumChessEngine engine)
        {
            var game = new Game(ObjectId.GenerateNewId(), engine);
            await ActiveGames_.InsertOneAsync(ChessBsonSerializationUtils.Serialize(game));

            return(game.Id.ToString());
        }
Ejemplo n.º 2
0
 public async Task <QuantumChessEngine> RequestEngine(string gameId)
 {
     using (var cursor = await ActiveGames_.FindAsync(FilterById(gameId))) {
         while (await cursor.MoveNextAsync())
         {
             var batch = cursor.Current;
             foreach (var document in batch)
             {
                 return(ChessBsonSerializationUtils.Deserialize(document).Engine);
             }
         }
     }
     throw new MongoException($"No game with gameId \"{gameId}\" found");
 }
Ejemplo n.º 3
0
 public async Task UpdateEngine(string gameId, QuantumChessEngine engine)
 {
     var replacement = new Game(new ObjectId(gameId), engine);
     await ActiveGames_.FindOneAndReplaceAsync(FilterById(gameId), ChessBsonSerializationUtils.Serialize(replacement));
 }