C++ iOS- need more information about Friendinfo & propertie

edited August 2013 in Native

First, I must say new iOS SDK 3.2.2 just rocks. It included the features I am looking for.
but the problem is, I didn't get any information about how to use them. :roll:
It would have been great help if we can have a demo for the same.

I am working on turn based game like poker. I am done with gameplay part of it, now remaining is all the add on features in the game like online friends, lobby UI for user, etc.

following are the points which I need to understand before moving ahead:

Friend Info class
I found this class in new sdk, I gone through the class but didn't get a way to assign other player with user as a friend. Is it need to be done at server side & I have to just use it as skeleton to store friend info?
if I call const Common::JVector<FriendInfo>& getFriendList(void); from where it will fetched friends data? how they linked with me, because I didn't find any setFriend kind of method.
I am bit confuse about it, can you please explain it in detail.

Players name & properties from same room in the lobby
how can I show players details along with rooms in the lobby, I am able to get all players data inside a room but outside room I am only able to get room data not players. I thought about adding players data into room's custom property but is it a good way to do it? it will be keep changing on players activity.

How can I create test scenarios
I want to create different rooms with different property, which I know how to create. but the problem is how can I create test scenario for the same? from my mac I can create one room from simulator & 1 more from my device, but how can I test for matchmaking & different rooms scenarios?
If you you can guide me to any method or tool, then I can move ahead from there.



  • > Friend Info
    Photon is only able to find players by name. It does not provide the actual social component (adding friends, etc). This is up to you or a middleware of your choice.
    We decided against designing and implementing another friend listing in Photon when most game-developers already have a favorite social API.

    > Players name & properties from same room in the lobby
    Neither player names nor other player properties are listed in the lobby. This is by design to keep the lists in manageable size. Without those constraints, it would become more complex to handle.
    You can search for friends with the server's help. It's just not possible to look them up on any clients.

    > How can I create test scenarios
    Build an executable and run it multiple times on your mac.
  • @FriendInfo:
    There is a new operation opFindFriends(). You pass an array with the names of the players that you want to look up. The client then asks the master server (the operation will fail, when you are in a game room, which implies being on a game server), if there are any players with these player names online and in which rooms they are, if in any.
    You would just pass your list of players into this operation, but handling who is on this list and who is not, is up to you. Functionality therefor is not provided for the reasons that Tobi has already mentioned.
    When you call this operation, the client lib removes the info that has been related to a potentially previous call and replaces it with the provided player list. It then sends this list to the server. After the server has answered, the client updates the list with the info that has been provided by the servers answer.
    getFriendListAge() returns 0 when the client is still waiting for the servers answer, so you can check its return value to find out when the friend list provided by getFriendList() will contain not only the player names provided by yourself, but also the info about these players, that has been provided by the server.

    @Player properties:
    These are only available from within a room. Only the room properties that are explicitly added to the list of properties to show in the lobby, will be provided to the lobby. However you could for example add a Dictionary with the player numbers as keys as a lobby presented custom room property.

    @Test scenarios:
    If you are only having one test device available (it would in general be a good idea to use at least two devices, one relatively up to date and one pretty old one, so that you can check how your game performs on different hardware generations), testing multiplayer with more than 2 players with iOS only gets problematic as Apple currently doesn't provide a way to open up more than one simulator in the same user account on the same Mac hardware.
    The best approach to this is to just use another platform for which Photon clients are available. For iOS development using the Photon OS X client lib comes in pretty handy: Not only is there a C++ SDK with the same API as on iOS available, but also Apples Cocoa framework for OS X provides everything that its sibling Cocoa touch for iOS does, except when it comes to UI. So you could abstract everything UI-related from you game and should then be able to get it running on Mac pretty easily. Then you can simply open up as many Mac clients of your game as your hardware is capable of (it's probably obvious that you should of course not run them in full screen).
    Alternatively you could of course also make a minimal port to another platform for which Photon C++ SDKs are available. Android could be a good option if you want to port your game there someday, anyway.
    Depending on your testing scenario you don't have to make a full port of your game, but a console app, which just shares the network logic with your game and sends certain events on key press may already be enough.
  • thanks Kaiserludi & Tobias for your reply.

    I will try out methods you have mentioned.
  • Hi,

    I am facing problem with friendInfo class, when I called "find friends" I only received 1 friend data, even after 2 users with same names are available.

    I am trying to search friend as follows:
    [code2=cpp]const ExitGames::Common::JString *friendName = ExitGames::Common::MemoryManagement::allocate<ExitGames::Common::JString>("Jhon");
    bool isFriendAvailable = mLoadBalancingClient.opFindFriends(friendName, 1);[/code2]

    & calling following method once received callback from server:

    [code2=cpp]void NetworkLogic::onFriendsInfoRecieved() //this function getting called once received callback from server
    if(mLoadBalancingClient.getFriendListAge() >= 0)
    CCLog("Friends Found %d",mLoadBalancingClient.getFriendListAge()); //this always returns 0

    for( int i=0; i< mLoadBalancingClient.getFriendList().getSize(); i++)
    CCLog(">>> Friends Data %s",mLoadBalancingClient.getFriendList().getElementAt(i).toString().UTF8Representation().cstr());

    Friends Found 0
    >>> Friends Data {Jhon on, not in a room}[/code2]

    even after 2 players with name Jhon are available it only returns contents of any one of the Jhon.

    Am I doing it right way or it's some bug?

    Please help.

  • Hi Paresh.

    You have to use unique playernames. For example you could generate them like this: userinput + some reserved character + a unique identifier (for example a timestamp or rand() as pseudo-unique identifier). You could then simply display the parts of the string before the reserved character to the player, if you want to. Another option would be to just let the player re-choose his name, when the previous choice is already taken. If you only use the names as unique ids for the players, but don't display them (you could also set display names as a separate custom property of the player), then you could just send an empty string as username. In that case the server will generate a unique id for you.
  • Hi,

    actually we are looking for wild card search where it will show all player names starting with given string. for eg. if I enter Jhon then it will return all name starting with Jhon like Jhonny, Jhon123, Jhon1980 etc.
    but from your explanation it not looking possible with photon search. Am I right or I can get any other help from photon server for searching friends?
  • Hi. Sorry, but wildcard-search for players is currently not possible. You would have to modify the server code for that.
  • thanks.

    after your reply I have decided to set unique player id for search, which is working fine.

    but I am getting friend list update as you mentioned in your previous post
    getFriendListAge() returns 0 when the client is still waiting for the servers answer, so you can check its return value to find out when the friend list provided by getFriendList() will contain not only the player names provided by yourself, but also the info about these players, that has been provided by the server.

    but it looks very tedious to keep checking for getFriendListAge() in update loop (for that time interval from request to respond.)
    can't we have callback for the same which will notify for find friend feedback?

  • Yes, makes sense.
    I will add that to the todo-list.
  • Thanks to you & Exit game team, I have progressed a lot in the game.
    now we are planning to start parallel development on android front with my colleague, can you please provide android sdk with above all issues fixed? I checked the sdk from download page, its old one.

  • So you need a build of the Photon Cloud AndroidNDK Client SDK, correct?
  • yes... which ever is latest & having all issues fixed which we discussed before.