Actor Properites Help

Options
tito.soriano
edited May 2011 in Native
Trying to set some actor properties on my iphone app.
I am using this join procedure and passing actor information through a NSMutableDictionary variable.
NSMutableDictionary* ev = [[NSMutableDictionary alloc] init];
//glat
[ev setObject:[NSString stringWithString:aHowl.glat] forKey:[KeyObject withByteValue:69]];
//glong
[ev setObject:[NSString stringWithString:aHowl.glong] forKey:[KeyObject withByteValue:70]];
-(void) joinRoom :(NSString*)gameroom :(NSMutableDictionary*) ev {
	NSLog(@"Joining Room: %@", gameroom);
	mGameID = gameroom;
	[m_pLitePeer opJoin:gameroom :nil :ev :YES];

}

When other actors receive the event that an actor has joined I can't seem to retrieve the individual actor properties.

Tried a couple different ways:
[(NSValue*)[photonEvent objectForKey:[KeyObject withByteValue:P_ACTOR_PROPERTIES]] getValue:&eventData];
		
eventData = (NSMutableDictionary*)[photonEvent objectForKey:[KeyObject withByteValue:P_GAME_PROPERTIES]];

NSString* test = (NSString*)[eventData objectForKey:[KeyObject withByteValue:69]];


Not sure if I should be looking in the "P_DATA" section of the PhotonEvent or not. Any help would be appreciate. Thank you.

Comments

  • Kaiserludi
    Options
    Hi tito.soriano.

    There should not be a P_DATA key inside the Dictionary. That key is used by raiseEvent.
    You can find the properties at the keys EV_RT_KEY_PROPERTIES, EV_RT_KEY_GAME_PROPERTIES and EV_RT_KEY_ACTOR_PROPERTIES, depending on the properties (should be EV_RT_KEY_ACTOR_PROPERTIES in your case) ("P_"-prefix for op-reponses, "EV_RT_KEY"-prefix for events, although they are identical in most cases).

    The only reason, that you could not find the properties in the join-event, is, that they are only sent with the join-event, if you pass true for the broadcast-flag to opJoin, but as you are actually doing that, so I guess, your properties are included in the event.

    You can check, if an expected entry is actually missing, or if you are just reading it out in an incorrect way (and look, which would be the correct way), by printing the dictionary to the debug out like this:
    printf("%s\n", [[NSString stringWithFormat:@"eventAction: %d %@", opCode, [Utils hashToString:returnValues :true]] UTF8String]);
    
    There should be a key 14 (for actor-properties), followed by an inner dictionary as value.

    try to read out your properties in the eventAction this way:
    eventData = (NSMutableDictionary*)[photonEvent objectForKey:[KeyObject withByteValue:EV_RT_KEY_ACTOR_PROPERTIES]];
    NSString* test = (NSString*)[eventData objectForKey:[KeyObject withByteValue:69]];
    
  • Thank you for replying

    I printed out the Event Action to debut window. This is the what got displayed.
    Join Info eventAction: 90 {(b)60=(b)90, (b)9=(i)2, (b)11=(n)[1, 2]}
    

    I can see clients joining but I have yet to see a key 14.

    Going to update to the lastest version of the iphone sdk and see if that helps. Do I need to be on the lastest version of the Server SDK for the actor properties to work?
  • Kaiserludi
    Options
    This feature is working fine for months now without breaking changes, so it should also work, if you do not use the most recent sdks. My only guess wouldbe, that you are not setting broadcast to true, but as you have pasted your code here and pass YES, which is defiend the same as true, I do not have any idea, why it is not working.

    You ould call LitePeer::opGetPropertiesOfActorWithByteKeys() oder LitePeer::opgetProperties() and print out the Dictionary, which you are getting back in response, to find out, if the properties have been set on the server. Also you could try to not pass them to opJoin, but set them with opSetProperties() after having joined, to isolate the problem.
  • It seems like the actor properties are not being sent to server app.

    I made the isoptional flag in lite join operation false.

    This is the message I get now from server:
    PhotonPeerReturn Message: Missing value 14 (JoinOperation.ActorProperties)

    Seems like the actor properties isn't getting sent. Here is my code to join.
    	NSMutableDictionary* ev2 = [[NSMutableDictionary alloc] init];
    	//fbid
    	[ev2 setObject:[NSString stringWithString:@"Test1"] forKey:[KeyObject withByteValue:70]];
    	//name
    	[ev2 setObject:[NSString stringWithString:@"Test1"] forKey:[KeyObject withByteValue:98]];		
    	//glat
    	[ev2 setObject:[NSString stringWithString:@"Test1"] forKey:[KeyObject withByteValue:96]];
    	//glong
    	[ev2 setObject:[NSString stringWithString:@"Test1"] forKey:[KeyObject withByteValue:97]];	
    	
    	[m_pLitePeer opJoin:gameroom :NULL :ev2 :TRUE];
    

    I've debugged the code and walked through it. I can see that the actorproperties for the join operation never trigger because of the null values.
                // set custom actor properties if defined
                if (joinOperation.ActorProperties != null)
                {
                    actor.Properties.SetProperties(joinOperation.ActorProperties);
                }
    

    Not sure where to go from there. I'll keep troulbshooting it but if you have any other ideas i'd appreciate it.

    Thanks
  • I figured it out. The "connectgame" and "joinRoom" were interfering with the saving of the actorproperties. I rearranged how the game started and when the actor join the game it work great.

    Appreciate all the help.
  • Kaiserludi
    Options
    Nice to hear, that you have found the issue.

    You mentioned about updating your Client SDK to the newest version, well we have just released version 6.5.0 today:
    viewtopic.php?f=8&t=546