MatchMaking not working in PhotonRealtime objc v3-2-5-3 sdk

cindyb2087
edited August 2014 in Native
I am hitting a strange issue where photon cloud match making is not working correctly. I want the photon clients to go to different rooms based on the room they select in UI. I see the below issues

Issue1:
When I specify room properties keys using NSValue my clients are always matched irrespective of what the values are in room properties dictionary.
Heres the sample code for the issue. I valiidate that [self getRoomId] returns the right room id based on user selection.
I invoke opJoinRandomRoom so that client joins an existing room if first. If that fails. I then call opCreateRoom in joinRandomRoomReturn

- (void) opCreateRoom
{
NSString* tmp = [NSString stringWithFormat:@%d, GETTIMEMS()];
nByte maxPlayers = 6;
NSDictionary* customRoomProps = [self getRoomProperties];
EGArray* lobbyProps = [self getLobbyProperties];

[mLoadBalancingClient opCreateRoom:tmp :true :true :maxPlayers :customRoomProps :nil :lobbyProps];

mStateAccessor.State = STATE_JOINING;
[mOutputListener writeLine:@creating room \%@\"", tmp];
}

- (void) opJoinRandomRoom
{
NSDictionary* customRoomProps = [self getRoomProperties];

nByte maxPlayersPerRoom = 6;

[mLoadBalancingClient opJoinRandomRoom:customRoomProps :maxPlayersPerRoom];
}

- (void) joinRandomRoomReturn:(int)localPlayerNr :(NSDictionary*)gameProperties :(NSDictionary*)playerProperties :(int)errorCode :(NSString*)errorString
{
EGLOG(EGDbgLvl::INFO, L"");
if(errorCode)
{
EGLOG(EGDbgLvl::ERRORS, L"%ls", errorString.UTF32String);
[mOutputListener writeLine:@opJoinRandomRoom() failed: %@", errorString];
mStateAccessor.State = STATE_CONNECTED;
[self opCreateRoom];
return;
}
EGLOG(EGDbgLvl::INFO, L"localPlayerNr: %d", localPlayerNr);
[mOutputListener writeLine:@game room \%@\" has been successfully joined", mLoadBalancingClient.CurrentlyJoinedRoom.Name];
[mOutputListener writeLine:@regularly sending dummy events now];
mStateAccessor.State = STATE_JOINED;
}

- (NSDictionary*) getRoomProperties
{
NSMutableDictionary* customRoomProperties = [NSMutableDictionary new];
int roomId = [self getRoomId];
nByte myKey = 11;
[customRoomProperties setObject:[NSValue value:&roomId withObjCType:@encode(int)] forKey:[NSValue value:&myKey withObjCType:@encode(nByte)]];
return customRoomProperties;
}

- (EGArray*) getLobbyProperties
{
NSMutableArray* propsArray = [NSMutableArray new];
nByte myKey = 11;
NSValue* myKeyNSValue = [NSValue value:&myKey withObjCType:@encode(nByte)];
[propsArray addObject:myKeyNSValue];
EGArray* egArray = [EGArray arrayWithArray:propsArray];
return egArray;
}

ISSUE2:
If I specify room properties keys using strings. The client are never matched even if the room properties values are same. I am not sure what is the right way to specify them. We are on a tight deadline. It would be great if you could help. To repro the second issue replace the getRoomProperties and getLobbyProperties above with the following code.
- (NSDictionary*) getRoomProperties
{
NSMutableDictionary* customRoomProperties = [NSMutableDictionary new];
int roomId = [self getRoomId];
NSString* myKey = @rid;
[customRoomProperties setObject:[NSValue value:&roomId withObjCType:@encode(int)] forKey:myKey];
return customRoomProperties;
}

- (EGArray*) getLobbyProperties
{
NSMutableArray* propsArray = [NSMutableArray new];
NSString* myKey = @rid;
[propsArray addObject:myKey];
EGArray* egArray = [EGArray arrayWithArray:propsArray];
return egArray;
}

Comments

  • Sorry that it took me so long to answer.

    1.
    For properties strings are the only type supported as key. All keys of other types will automatically get removed, so it is expected to behave like if you would never have added your property with its NSValue key.

    2.
    Please change the line
    [code2=cpp][mLoadBalancingClient opCreateRoom:tmp :true :true :maxPlayers :customRoomProps :nil :lobbyProps];[/code2]
    into
    [code2=cpp][mLoadBalancingClient opCreateRoom:tmp :true :true :maxPlayers :customRoomProps :lobbyProps];[/code2]

    The EGLoadBalancingClient::opCreateRoom() overload with the customLocalPlayerproperties parameter has been removed from the API (custom local player properties should be supplied via class EGLoadBalancingMutableRoom). It' base class EGLoadBalancingPeer however still offers an overload with that parameter, so your code doesn't call the Clients, but the Peers implementation of that method, which results in undefined behavior. To avoid this issue in the future, we plan to let the Client wrap the Peer instead of inheriting from it in a future release of the ClientSDK.

    Afer applying the mentioned change your code variant 2 works fine for me.