Player properties not setting

m9gamesm9games
edited July 2013 in Native
Hello,

I am working forward on my game. Btw, thank you for the help on my previous issue. This time the prblem is that when I set the custom properties if the player during initialization of the Loadbalancing Client, they are set properly. Now my game requires that I change the value of one of the properties during joinroomreturn(). When I try doing so, it does not set. This is how I do it:

mLoadBalancingClient.getLocalPlayer().addCustomProperties(hashTable);

I also tried setting it in the opcreateroom() just to see if the values can be changed on the go. It did work!! Is there something wrong that I am doing!!

Thank you in advance!!

Comments

  • Hi m9games.
    This is a bug in ExitGames::LoadBalancing::Peer.
    It will be fixed in the next release. Until then you can already do that fix yourself for the version that you are currently using, as the bug is in the open source part of the code.

    Please open the LoadBalancing project file in the SDK and look for Peer.cpp there. In that source file you should find a function names opSetPropertiesOfPlayer(). In that function there should be a line "op.put(Lite::ParameterCode::ACTORNR, ValueObject<nByte>(playerNr));" The scope of the ACTORNR key may be different depending on your version, as we have changed it in the past. Please change that "nByte" to "int". After that, rebuild all configs of the project. With the resulting library binaries it should then also work from within the joinRoomReturn() callback.
  • Hi,

    I did make the changes you mentioned in Peer.cpp. After doing so I tried a clean and build on my project. It does not seem to work that way. I think there is a different way to build the photon library!!

    Can you please guide me on doing so?? As the changes that I have made are not reflecting when I run my project.

    Thank you again.
  • Just clean and rebuild is fine and will create a new LoadBalancing lib. Of course you should assure that you build all configs that you are using and that you replace the lib binaries that you game links to with the freshly build ones. Depending on the IDE that you are using, you should also do a clean and rebuilt of the game project to assure that it's indeed using the new binaries and has not cached the replaced ones somewhere.
    What exactly do you mean with "It does not seem to work that way." ?
  • Hi,

    I meant that I tried clean and build with the game project but that did not work. What I wanted to ask is how should I build photon?

    I use Eclipse for development but I assume that to rebuild photon, I will have to use Visual Studios. Please let me know if I am correct??

    If so, please also guide me with the steps to follow as I am not familiar with VS...


    Thanks a ton for all your help.
  • Hi.

    Which IDE you will have to use depends on the paltform for which you are trying to build:
    Android: VS + vsandroid, BB 10: QNX Momentics, iOS: Xcode, Linux: Code::Blocks or makefiles, Marmalade: VS or Xcode, OS X: Xcode, PS3: VS, Windows: VS

    I am not talking about rebuilding the complete Photon client. It consists of 3 parts, Common, Photon and LoadBalancing. The first 2 are closed source, so you can't modify and rebuild them anyway. The LoadBalancing layer is open source and can be modified and rebuilt. Just open the solution/workspace or project file in the IDE that matches the entry in the list above (from you profile and your previous threads I can tell that you are using Android, so it would be VS 2010 with vsandroid plugin; in the rest of this post I will assume that that info is up to date).

    In VS just choose Build from the top menu and click on build solution and it will output a new .a file for the LoadBalancing lib. Make sure that you have chosen the right entries for the drop down menus at the top of the IDE for the config (debug vs. release and arm vs,. armv7, with and without rtti, you should rebuilt at least all of them that you are actually using) and platform (has to be set to Android in your case).
  • Hi,

    I followed your instruction on building the Loadbalancing project to get the .a files. But the issue that I face now is a little away from photon.

    When I try and build the files using Visual Studios and vsandroid, I get an error in a particular file of VS. It is because this particular file is a 32bit file and I run 64bit OS on my system. I tried various combinations like downgrading from VS2012 to VS2010. I also tried it on a 32bit system, but seems that due to my inexperience with VS, I fail to get the builds out.

    My request to you would be that if you can PLEASE make those changes in peer.cpp and build the .a files for me. My game is stuck till I get this particular feature working correctly and thus all our deadlines will get delayed.

    Hope you can help me with this. Also are there any probabilities of another Photon update sometime soon??

    Thanks a ton.
  • It should work just fine with a 64bit Windows, but you currently have to use VS 2010 to open the project or solution file.

    However please try this build for prebuilt libs including the described fix:
    https://dl.dropboxusercontent.com/u/429 ... ud_SDK.zip
  • Hi,

    Thank you for all your help Kaiserludi!! But it seems that nothing is working out for me. I tried using the package that you shared, but it still does not give any positive results. I still get the playerproperties in the callback as an empty hashtable.

    Can you please help on how exactly should I set the properties of player. The code that I am using is:

    mLoadbalancingCLient.getLocalPlayer().addCustomProperties(hashtable);

    I call this as soon as I create the client and then I need to change particular property values..

    Also is it possible for you to change the type of ACTRNR in Peer.cpp and then send me the built package??

    Thanks again..
  • I have already sent you that package. It's the one that I have linked in my last post and I have verified that it works correctly with that package.
    You are aware that for properties strings are the only supported key types?
  • HI,
    I unable to get the issue resolved yet, even after all the help that you provided. I think there is something very basic that I might be doing wrong, unknowingly. So here is what I am doing:
    The constructor of my Listener class looks like this:

    [code2=cpp]NetworkLogic::NetworkLogic(const char* appVersion)
    #ifdef _EG_MS_COMPILER
    #pragma warning(push)
    #pragma warning(disable:4355)
    #endif
    : mLoadBalancingClient(*this, "appId", appVersion, clientname),
    mLastInput(INPUT_NON)
    #ifdef _EG_MS_COMPILER
    # pragma warning(pop)
    #endif
    { playerPropertiesHash.put("property1", "4");
    playerPropertiesHash.put("property2", "4");
    playerPropertiesHash.put("property3", "456");
    playerPropertiesHash.put("property4", "4");
    mLoadBalancingClient.getLocalPlayer().addCustomProperties(playerPropertiesHash);
    }[/code2]

    In my game, I need to change property3 when the player connects to a room.
    Now, when a player connects to a room or creates the room, we get the call back in joinRoomReturn, joinRandomRoomReturn and createRoomReturn. In my case lets say that my player creates the room. So the callback is:

    [code2=cpp]void NetworkLogic::createRoomReturn(int localPlayerNr, const ExitGames::Common::Hashtable& roomProperties, const ExitGames::Common::Hashtable& playerProperties, int errorCode, const ExitGames::Common::JString& errorString)
    {
    if(errorCode)
    {
    gameState = STATE_CONNECTED;
    return;
    }

    playerPropertiesHash.put("property3","50");
    mLoadBalancingClient.getLocalPlayer().addCustomProperties(playerPropertiesHash);
    gameState = STATE_JOINED;
    }[/code2]

    After the above mentioned callbacks, we get another common callback joinRoomEventAction. My expectations are that I should get the updated property3 when the joinRoomEventAction is called. So I try to retrieve it like this:

    [code2=cpp]void NetworkLogic::joinRoomEventAction(int playerNr, const ExitGames::Common::JVector<int>& playernrs, const ExitGames::LoadBalancing::Player& player)
    {
    CCLog("Players in room %s", player.getCustomProperties().toString().UTF8Representation().cstr());
    gameState = STATE_PLAYING;
    }[/code2]

    But in the CCLog, I get property3 as 456 instead of 50.
    IMP: When I tried the same flow with the IOS version of Photon, I get property3 as 50 in the logs.
    Is it that, I am doing it the wrong way, or is it really an issue with Photon.
    Thank you for all the help :-)
  • I works just fine with the iOS version? That's interesting because the iOS client is using the same codebase as the Android one, so if the same version is working on one OS, it should definitely also work on the other one.

    What exactly is your testing scenario in which it doesn't work and how does it look when it works?
    Android client creates the room and iOS one joins it or vice versa or are both clients using the same OS and it works with 2 iOS, but not with 2 Android clients? In the latter case does anything change if you mix the clients?

    How long do you wait after room creation until joining? Please keep in mind that if the creating client updates it's properties, it has to send that update out to the server first and the server can only already provide the joining one with the updated value if the update has arrived before the join request, otherwise it will provide it with the old properties and then when the update has arrived, the joined player gets informed by a call to the onPlayerPropertiesChange() callback (implementation of that callback is optional and not implemented by the demo by default!).

    You could also run the client in the emulator and check with wireshark, if the data actually leaves the client.
    Another thing to try would be to download the Photon Server SDK and run a Photon server on a local Windows machine and let your clients connect to that Photon instance, so that you can have a look at the server logs and can also check with wireshark, what data arrives from one, what gets out to the other and at which point in time that happens.
  • Hi,

    As for your queries on my testing scenarios, the problem occurs when I try 2 Androids, but works fine with 2 IOSs. I havent tried mixing the two platforms. For Androids, I create a room with Android1 and in its joinRoomReturn, I call addCustomProperties() to set the value of a particular property. Then I try to read the value of the property in joinRoomEventAction(), where it still gives the old value.

    I then connect Android2 and join the room created by Androi1. Now on this device also I change the property in joinRoomReturn(). Here in joinRoomEventAction(), I get the new value of the property of Android1. But Android2 is still the old value.

    On the other hand, in Android1, I get the old values for properties of both devices. Also I use a for loop to getPlayers() from currently joined room and for each player I do player.getCustomProperties().

    I am trying to get a work around because, I think it is not giving me correct values from within the callbacks. I want to try and access the values when updating my UI. The new package you shared has the Hastable in customEventAction to Object. Due to this, I get crashes when calling opRaiseEvent and customEventAction callback. I was using Hashtables earlier.

    I am not being able to cast between Hastable and Object. Can you please help me with the same.

    Thanks a lot..
  • Hi,
    I tried a lot of ways to get this thing working. I think I might have found a small breakthrough. As you mentioned in your last post that it might be due to the timing of the updates and the requests, I put a delay when retrieving the values.
    After playing with the delay value for quite long, I conclude that it takes a minimum of 10 seconds for the update to reflect. To support this I also implemented the override of onPlayerPropertyChange(). I got the logs in it only after I put the delay value to 10 seconds.
    It seems to be unusual that the same code reflects the update immediately in the IOS version. As for the network, I use the same connection for both the platforms.
    I will carry on my development with this delay, but have to get rid of it or at least bring it down to a tollerable time. Can you please help me with any work arounds so that I can reduce the delay, cause this long will extend my single game session considerably and would also compromise on user experience.
    Thank you...
  • Hi.

    No, you can't cast an Object instance into a Hashtable instance, because Object isn't a common baseclass for the various containers, but rather a wrapperclass, thats able to hold a payload of any of the supported types.

    You can use the following code to read out a Hashtable instance from an Object instance:
    [code2=cpp]Hashtable testHash = ExitGames::Common::ValueObject<ExitGames::Common::Hashtable>(obj).getDataCopy();[/code2]

    If you don't test with mixed devices then it's harder to find out if the problem is on the sending or on the receiving side.

    You are testing with the new package, right?

    Could you please explain how you are applying that delay? It shouldn't matter at all for the onPlayerPorpertiesChange() callback, as it will be called, when the update arrives, no matter, when it arrives.

    Are you doing anything different on iOS than on Android?
Sign In or Register to comment.