How can lobby users detect when room properties have changed?

0 votes

I am trying to update the list of rooms that are open for seating in the lobby.  I'd like to remove any rooms where the games have been started.

I notify the server that that the room property has changed with:

        std::map<std::string,std::string> properties;
        std::vector<std::string> removeArray;
        AppWarp::Client::getInstance()->updateRoomProperties(roomId, properties, removeArray);


But how do I get a user in the lobby to detect this change?

I've tried adding

void HelloWorld::onUserChangeRoomProperty ( AppWarp :: room event , std :: string username , std :: map < std :: string , std :: string > properties , std :: map < std :: string , std :: string > lockTable )

    CCLog("Property Changed");


void HelloWorld::onUpdatePropertyDone ( AppWarp :: liveroom event)

    CCLog("Property Changed");

But neither have fired.  I know the property is being set because the rooms disappear when I manually refresh it. 

asked Mar 1, 2014 in AppWarp by PhilipJFry (36 points)
retagged Mar 11, 2014 by shepAdmin

1 Answer

0 votes
To get notified about any event occurs in a room, you need to subscribe that particular room. Then the "onUserChangeRoomProperty" callback of Notification listener will be called in response of "updateRoomProperties".
answered Mar 1, 2014 by rajeev.etc (1,660 points)
But I don't want everyone in the lobby to subscribe to every room (which isn't possible anyway).  What is the work around here?  How do I keep my list of rooms open to seating up to date in the lobby?
If you can't subscribe to the room in which the properties are changing - then the other way is to poll with the getRoomWithProperties API. It will return to you a list of rooms that satisfy given properties. So in your case you will call with ("closed", false)
That was the solution I was just about to implement.  What do you think a reasonable interval for that would be? I currently have it at .2 seconds, but I'm thinking that might be overkill.
Yes, that is excessive - probably 1 second is fine. Btw, do your games have a fixed number of players? Asking as otherwise you can also use getRoomInRange API instead of having a separate property for "closed".
I have a maximum of 4, but it works with 2-3.  When a user joins, I start a countdown clock of 5-10 seconds (haven't decided on the final number yet) that keeps the table open as long as there are people joining the match.  My plan is to only ping for that amount of time once I get the "userjoinedroom" event.  That way, I'm not overloading the server with unnecessary messages.
Hi PhilipFry - hope the solution in which you poll ~ 1 second for rooms which are not closed worked for you.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on