objective-ccocos2d-xgame-center

Game Center multiplayer matchmaking issue


I am trying to create a real time multiplayer game using Game Center. For matchmaking, I am using programmatic approach by using the following code:

[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
        if (error)
        {
            // Process the error.
            NSLog(@" error => %@ ", [error userInfo] );

        }
        else if (match != nil)
        {
            NSLog(@"Match Found _-----------");
            currentMatch = match;
            match.delegate = self;

            NSLog(@"Expected player count:%ld",match.expectedPlayerCount);

            if ( match.expectedPlayerCount == 0)
            {
                NSLog(@"Ready to start match!");

            }
        }
    }];

Currently, the code generates following error when a match is found:

ABC-mobile[342:26698] [log]  [ERROR] ReXmitCollectionRequest:640 /BuildRoot/Library/Caches/com.apple.xbs/Sources/AVConference/AVConference-1020.31/ICE.subproj/Sources/ICEMessage.c:640:     ReXmit [SNATMAP_REQUEST] (1:0) from [192.168.0.104:16402] to [17.133.234.32:16384] failed (801A0002)

ABC-mobile[342:26698] [log]  [ERROR] -[GKConnectionInternal internal_setRemoteConnectionData:fromParticipantID:pendingConnectionPIDList:]:1041 GCKSessionPrepareConnection FAILED(80150016)

I am using Cocos2D-X game engine and I am calling this method from a C++ function.

I would appreciate any suggestions and thoughts on this topic. Thank you.


Solution

  • Solution:

    Use pure Objective-C code (file should have .m extension instead of .mm). Write a wrapper class in Objective-C++ (file with .mm extension) to call these Game Center methods.