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

  • SEARCH
  • Home
  • 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 8970677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:46:00+00:00 2026-06-15T17:46:00+00:00

I’m wondering how do I get the disconnect message for local player when the

  • 0

I’m wondering how do I get the disconnect message for local player when the game session is in progress and we’re unable to communicate our data to other players. As there is nothing in documentation that says “this method will inform you whenever your connection fails”, I’m at a bit of a loss.

I was trying to use this chunk of code in hopes that it would work, but it’s futile. The “We’re disconnected.” message is never triggered.

- (void)match:(GKMatch *)theMatch player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state {
  if (self.match != theMatch) return;

  switch (state) {

    case GKPlayerStateDisconnected:
      //disconnected
      NSLog(@"player status changed: disconnected");
      matchStarted = NO;
      GKLocalPlayer *player = [GKLocalPlayer localPlayer];
      if ([playerID isEqualToString:player.playerID]) {

        // We have been disconnected
        NSLog(@"We're disconnected.");
      }
      if ([delegate respondsToSelector:@selector(matchEnded)]) {
        [delegate matchEnded];
      }
      break;
  }
}

The only other line that I found might tell us that we’re unable to communicate is when we actually send data like this:

- (void)sendRandomMatchData:(NSData *)data {  
  GKMatch *match = [GCHelper sharedInstance].match;
  BOOL success = [match sendDataToAllPlayers:data
                                withDataMode:GKMatchSendDataReliable
                                       error:nil];
  if (!success) {
    [self matchEnded];
  }
}

But I assume that “success” will also be false if the opponent has disconnected and we’re unable to send messages to them.

I have a pretty strict game logics, if someone has been disconnected I need to inform them that they are unable to continue playing the match and that they have lost.

Any help is highly appreciated.

  • 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-06-15T17:46:01+00:00Added an answer on June 15, 2026 at 5:46 pm

    What about examining the error after the following code line:

      BOOL success = [match sendDataToAllPlayers:data
                                    withDataMode:GKMatchSendDataReliable
                                           error:nil]; //replace nil with NSError variable
    

    Maybe error will give you extra info u need.
    Another idea is to create NSTimer and set some certain time for making moves/turns. If some player didn’t make it for a certain time then assume this player is disconnected. Also you could check your Internet connection state to determine you have a connection cuz maybe you just lost it and that’s the reason you can’t send/receive any data.
    Also you could check every player periodically by sending them some short amount of data using GC just to make them answer you. This way you could ensure all players are “alive” or detect some “zombie”.
    Remember if player moves the game to background using Home button you won’t detect it anyhow cuz code in your game wont execute. And this situation doesn’t mean that player is “zombie”. Player could be busy by a call or something else like another app. Player could temporary loose Internet connection. This means that he/she could return to game soon…

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I know there's a lot of other questions out there that deal with this
I have been unable to fix a problem with Java Unicode and encoding. The
I want to construct a data frame in an Rcpp function, but when I
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.