How do you use the CustomRoomData on Appwarps with cocos2d-x

329 Views Asked by At

Just started coding with Appwarps and I'm running into an issue. I have a lobby built that shows live rooms, but I really do not want to show the rooms for matches that have already started. I figured I would use

void Client::setCustomRoomData(std::string roomId, std::string customData)

But I have some doubts on how to use it. Once the game starts, I plan on sending

SetCustomRoomData(roomId, "Closed");

to notify the server that open seating is now closed. However, when I check the room properties on another device when it calls

void CCAppwarpDelegate::onGetLiveRoomInfoDone(AppWarp::liveroom revent)
{
CCLog("CustomData=%s",revent.customData.c_str());
...

it returns blank. What am I missing here? Besides the code not working, what really makes me question myself is that I don't understand the mechanics of the properties. How do you have multiple custom properties since you aren't assigning it any kind of index...or do room only have a single custom property at any given time?

1

There are 1 best solutions below

1
On BEST ANSWER

You don't need to use customData and instead use only room properties. Room properties is a set of key/value pairs that you can associate with a room.

I recommend you read the following link http://appwarp.shephertz.com/game-development-center/matchmaking-basic-concept/

So the flow is as follows -

  1. you first create the room using the createRoom API and pass a properties dictionary containing <"closed", "false">.

  2. Then once the game is active, you use updateRoomProperties API on the room and pass <"closed", "true"> to the API.

  3. Then when you want to show the list you should use getRoomWithProperties and pass <"closed", "false">. This will get you a list of rooms that are not yet "closed".