public void Room_CreateRoom(string gameType, string roomName, UserLogicModel user,
            Action<RoomDataModel> onRoomCreated)
        {
            //ExtensionMethods.debugger();

            RoomDataModel rd = new RoomDataModel(gameType, roomName, roomName + "RoomName", roomName + "GameRoom",
                new List<UserLogicModel>() {user});
            manager.client.Collection("Room",
                (err, collection) =>
                {
                    collection.Insert(rd);

                    onRoomCreated(rd);
                });
        }
        public void Room_RemovePlayer(RoomDataModel room, UserLogicModel user, Action<RoomDataModel> complete)
        {
            manager.client.Collection("Room",
                (err, collection) =>
                {

                    JsDictionary<string, object> query = new JsDictionary<string, object>();

                    query["$pop"] = new {players = user};

                    collection.Update(new {_id = MongoDocument.GetID(room.ID)},
                        query,
                        (err2) =>
                        {
                            if (err2 != null) ServerLogger.LogError("Data Error: " + err2, user);

                            foreach (var userLogicModel in room.Players)
                            {
                                if (userLogicModel.UserName == user.UserName)
                                {
                                    room.Players.Remove(userLogicModel);
                                    break;
                                }
                            }

                            complete(room);
                        });
                });

        }
 public void Room_DeleteRoom(RoomDataModel room)
 {
     manager.client.Collection("Room",
         (err, collection) => { collection.Remove(new {_id = MongoDocument.GetID(room.ID)}); });
 }
        public void Room_AddPlayer(RoomDataModel room, UserLogicModel user, Action<RoomDataModel> complete)
        {
            manager.client.Collection("Room",
                (err, collection) =>
                {

                    JsDictionary<string, object> query = new JsDictionary<string, object>();

                    query["$push"] = new {players = user};

                    collection.Update(new {_id = MongoDocument.GetID(room.ID)},
                        query,
                        (err2) =>
                        {
                            if (err2 != null)
                                ServerLogger.LogError("Data Error: " + err2,user);
                            room.Players.Add(user);

                            complete(room);
                        });
                });

        }