Get list of rooms

edited January 2013 in Native
Hello, I am a user of marmalade and so far I have used photon to create random connections, and the version I have not updated in a while.
I wish I knew how to get a list of the rooms created in the lobby so you can choose which room to connect. I've been looking but I have a bit of trouble for the changes since I updated.

The code I've used so far is as follows:

Connection:

NetworkLogic :: NetworkLogic (OutputListener * listener, const char * appVersion)
# ifdef _EG_MS_COMPILER
# Pragma warning (push)
# Pragma warning (disable: 4355)
# endif
: MOutputListener (listener)
, MLoadBalancingClient (* this, "xxxxxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxx" appVersion, PLAYER_NAME)
, MLastInput (INPUT_NON)
# ifdef _EG_MS_COMPILER
# Pragma warning (pop)
# endif
{
mStateAccessor.setState (STATE_INITIALIZED);
mLoadBalancingClient.setDebugOutputLevel (DEBUG_LEVEL_INFO);
}



Creating and binding rooms:

NetworkLogic :: opCreateRoom void (void)
{
ExitGames :: jstring tmp;
ExitGames :: Hashtable room;
room.put (ExitGames :: KeyObject <ExitGames::JString> (L "mode"), ExitGames :: ValueObject <int> (2));
ExitGames :: Hashtable player;
player.put (ExitGames :: KeyObject <ExitGames::JString> (L "name"), ExitGames :: ValueObject <ExitGames::JString> (L "unknow"));
ExitGames :: JVector <ExitGames::JString> lobby;
lobby.addElement (ExitGames :: jstring (L "mode"));
mLoadBalancingClient.opCreateRoom (tmp = (int) GETTIMEMS (), true, true, 2, room, player, lobby);
mStateAccessor.setState (STATE_JOINING);
}

NetworkLogic :: opJoinRandomRoom void (void)
{
ExitGames :: Hashtable room;
room.put (ExitGames :: KeyObject <ExitGames::JString> (L "mode"), ExitGames :: ValueObject <int> (2));
ExitGames :: Hashtable player;
player.put (ExitGames :: KeyObject <ExitGames::JString> (L "name"), ExitGames :: ValueObject <ExitGames::JString> (L "unknow"));
mLoadBalancingClient.opJoinRandomRoom (room, 2 player);
}



If you would be so kind to tell me about that I view the list of rooms and you choose to join the ... greetings and thank you very much.

Comments

  • Hi anibaleon1989.

    1. Please use the appropriate subforum. A Marmalade related question has nothing to do with Photon Unity networking at all. I have moved your thread accordingly.

    2. It would be a great help if you could simply tell us the exact client SDK version, that you are using, so that I don't have to guess about it.

    3. Have you written that code in the forums post editior from scratch? It looks kind of scratch with syntax errors like jstring instead of JString, etc. Also please use the code-tags for example code, to make it more readable.

    4.
    Use
    [code2=cpp]mLoadBalancingClient.getRoomList();[/code2]
    or if you just need a list of the names of the rooms and no futher room properties, then you can instead use
    [code2=cpp]mLoadBalancingClient.getRoomNameList();[/code2]

    getRoomList() returns a JVector of class LoadBalancing::Room, while getRoomNameList() returns a JVector of class JString. Please have a look at these 3 classes and their docs on how to use them.

    You can the join a room by name in the following ways (with "i" being the index of the room to join in the JVector:
    [code2=cpp]mLoadBalancingClient.opJoinRoom(mLoadBalancingClient.getRoomList().)getName();
    mLoadBalancingClient.opJoinRoom(mLoadBalancingClient.getRoomNameList());[/code2]
Sign In or Register to comment.