cloud: getting room custom properties

Options
Hi,

I have a problem with photon cloud. I'm trying to get the custom properties of the room from both the host and the client user but only the seem to be able to get them. (By host, I mean the user that created the game)

[code2=as3]private var peer:LoadBalancedPeer = PhotonPeer.getInstance();

var gp:GameProperties = GameProperties.createDefault();
var custom:Dictionary = new Dictionary();
custom["player1"] = 1;
custom["gameId"] = 10;
gp.customProperties = custom;
peer.opCreateGame("", gp);[/code2]
THIS is what doesn't work - it returns null for the host user and a Dictionary() object for the client (which is the correct object)
[code2=as3]// ** in another class after the game is created or joined ** //
peer.getGameProperties().customProperties;[/code2]

I've tried a bunch of stuff but I can't get the customProperties with the host user.

What to do?

Comments

  • vadim
    Options
    Hi,
    Can you check please if loadBalancingExample works for you?
    onCreateGameClicked method in ScreenMasterConnected.as looks very similar to your code
  • onCreateGameClicked does the thing that works fine in my example - it's the last line that doesn't work for the host.
  • vadim
    Options
    Seems like example sets game properties by itself on response:
    [code2=as3]public class ScreenGameConnected extends ScreenController
    {
    ...
    override protected function addListeners():void {
    ...
    LoadBalancedPeer.getInstance().addEventListener(CreateGameResponse.TYPE, onCreateGameResponse);
    LoadBalancedPeer.getInstance().addEventListener(JoinGameResponse.TYPE, onJoinGameResponse);
    ...
    private function onCreateGameResponse(r:CreateGameResponse):void
    {
    LoadBalancedPeer.getInstance().setGameProperties(r.getGameProperties());
    updateGameProperties();
    }

    private function onJoinGameResponse(r:JoinGameResponse):void
    {
    LoadBalancedPeer.getInstance().setGameProperties(r.getGameProperties());
    updateGameProperties();
    }[/code2]
  • I've solved it by saving the gameproperties as a class variable in my join game screen, and set it with peer.setGameProperties(gameProps); in my onUserJoin method.

    Still don't understand why this is necessary...
  • vadim
    Options
    I believe too that game properties should be updated automatically.
    Looks like bug. Since old flash api (v 3.0) is not updated anymore manual properties update is necessary until you use that api.