Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:32:37+00:00 2026-05-22T17:32:37+00:00

How would I end a match/disconnect the opposing player and/or remove the match maker

  • 0

How would I end a match/disconnect the opposing player and/or remove the match maker standard interface (GameKit), if the Home button on the device is pressed? I also have a “Main Menu” button on screen and if that is pressed, I would like to end the match/disconnect the opposing player. I’m using GameKit to find and start matches.

I am new to multiplayer so any help is appreciated.

-(void) match:(GKMatch*)match player:(NSString*)playerID didChangeState:(GKPlayerConnectionState)state
{
    switch (state)
    {
        case GKPlayerStateConnected:
            [delegate onPlayerConnected:playerID];
            break;
        case GKPlayerStateDisconnected:
            CCLOG(@"Disconnected");
            [delegate onPlayerDisconnected:playerID];
            break;
    }

    if (matchStarted == NO && match.expectedPlayerCount == 0)
    {
        matchStarted = YES;
        [delegate onStartMatch];
    }
}


-(void) disconnectCurrentMatch
{
    CCLOG(@"Quit Match");
    [currentMatch disconnect];
    currentMatch.delegate = nil;
    [currentMatch release];
    currentMatch = nil;
}

That is all I am using to disconnect players. Then when the player presses the “Main Menu” button this is the code.

-(void)Menu: (id) sender
{
    didQuit = YES;

    if (isSingle == YES)
    {
        GameKitHelper* gkHelper = [GameKitHelper sharedGameKitHelper];
        [gkHelper disconnectCurrentMatch];
        gkHelper.delegate = nil;
    }

    [[CCDirector sharedDirector] replaceScene: [MainMenu scene]];
    CCLOG(@"Return Main Menu");
}

It replaces the scene to the Main Menu, but never changes the state to disconnected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:32:38+00:00Added an answer on May 22, 2026 at 5:32 pm

    Jon,

    When the home button is pressed, your application delegate will receive the -(void)applicationDidEnterBackground:(UIApplication*)application callback.

    You have roughly 5 seconds (before Springboard kills your app) to do whatever you need to do to clean up your app (unless you need more time, which you can request from iOS, but aren’t guaranteed to receive).

    How do you “clean up”? As you mentioned – your match has 2 players, so either player disconnecting or quitting has the same effect on the game – ending it (assuming that a player cannot continue to play on by him/herself).

    Your leaving player will send a -disconnect message to GameKit.

    The player left behind’s program needs to have an object that conforms to the GKMatchDelegate protocol and receives callbacks as the delegate of GKMatch.

    When an opposing player disconnects, GKMatch will call to the delegate with:

    - (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state`
    

    So, now your player that has been left behind’s code will have also been notified. In that method, check if it’s disconnection – and if so, follow your own logic for what you want to happen when a player is “hung up on”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: for attribute in site.device_attributes device.attribute end where I would
On the other end of the spectrum, I would be happy if I could
I would like to do the following: $find = "start (.*) end"; $replace =
i have a basic ruby class: class LogEntry end and what i would like
I'm using CVS on Windows (with the WinCVS front end), and would like to
Would the following SQL remove also the index - or does it have to
I would like to remove/delete a migration file. How would I go about doing
Would it not make sense to support a set of languages (Java, Python, Ruby,
Would it be possible to print Hello twice using single condition ? if condition
Would it be possible to show an image in full screen mode using silverlight.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.