है, मैं गेम सेंटर के माध्यम से मल्टीप्लेयर मोड के साथ एक टर्न-आधारित गेम लागू कर रहा हूं। मेरे पास सैंडबॉक्स मोड में परीक्षण करने के लिए 2 डिवाइस (1 आईपैड, 1 आईफोन) हैं जो ठीक काम कर रहे थे लेकिन हाल ही में ऑटो ऑटोमेकिंग प्रक्रिया में संघर्ष करना शुरू हो गया है। एक उपयोगकर्ता से पहली बार भेजने के बाद, दूसरी डिवाइस तुरंत उस गेम को पहचान नहीं पाती है लेकिन अपना खुद का ताजा गेम खोलती है। इससे पहले कि यह तुरंत दूसरे डिवाइस में शुरू हुआ गेम स्पॉट करने में सक्षम था और मैचमेकिंग काफी सरल थी। और मुझे मेलमेकिंग के लिए प्रासंगिक किसी भी हिस्से को बदलने की याद नहीं है (NSCoding
, GKTurnBasedEventHandler
, GKTurnBasedMatchmakerViewControllerDelegate
प्रतिनिधि विधियां आदि)।गेम सेंटर मैचमेकिंग GKTurnBasedMatch में महत्वपूर्ण अंतराल (~ 1 मिनट)
अब मैं एक डिवाइस से पहली बार भेजता हूं और लगभग 1 मिनट तक प्रतीक्षा करने की आवश्यकता है ताकि अन्य डिवाइस उस गेम से सफलतापूर्वक कनेक्ट हो सके। कनेक्शन समाप्त होने के बाद EndTurnWithMatchData किसी भी समस्या के बिना काम करता है, यह 1-2 सेकंड के भीतर डेटा भेज और प्राप्त कर सकता है। लेकिन यदि उपयोगकर्ता एक नया गेम शुरू करते हैं और 1 मिनट तक इंतजार करना चाहते हैं तो यह एक अच्छा यूएक्स नहीं होगा, इसलिए कोई अन्य उपयोगकर्ता अपने गेम से जुड़ सकता है। क्या ऑटो ऑटोमेकिंग प्रक्रिया में कोई भी महत्वपूर्ण अंतराल अनुभव कर रहा है? मैंने अभी तक निमंत्रण लागू नहीं किए हैं, इसलिए मैं इसे जांच नहीं सकता। एनएसकेएड आर्चिवर के साथ मैचडाटा I संग्रह बहुत बड़ा था, 33 9 6 बाइट, यहां तक कि लगभग कोई डेटा के साथ एक ताजा गेम के लिए भी।
GameOptionsViewController
:
- (void)turnBasedMatchmakerViewControllerWasCancelled:(GKTurnBasedMatchmakerViewController *)viewController
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFailWithError:(NSError *)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match
{
[self dismissViewControllerAnimated:NO completion:nil];
self.gcMatch = match;
[self performSegueWithIdentifier:@"GameMultiplayer" sender:self];
}
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"GameMultiplayer"])
{
GameViewController *GameVC = (GameViewController *)segue.destinationViewController;
[GameVC setGameMode:GAMEMODE_MULTIPLAYER_SAMEDEVICE];
//Multiplayer game it is
if(self.gcMatch != nil)
{
[GameVC setGameMode:GAMEMODE_MULTIPLAYER_GAMECENTER];
GameVC.gcMatchDelegate = self;
GameVC.gcMatch = self.gcMatch;
NSLog(@"Game OVC Segue: Match ID | %@", self.gcMatch.matchID);
}
}
else
{
...
}
}
GameViewController
:
//This method is called according to user actions
//It's the only method I use to send data to other participant
-(void) sendCurrentGameDataWithNewTurn:(BOOL) newTurn
{
NSLog(@"Sending game data current participant : %@", gcMatch.currentParticipant.playerID);
//Update match data if it is corrupted anyhow
if (gcMatch.currentParticipant == nil)
{
[GKTurnBasedMatch loadMatchWithID:gcMatch.matchID withCompletionHandler:^(GKTurnBasedMatch *match, NSError *error)
{
if (error != nil)
{
NSLog(@"Error :%@", error);
return ;
}
[self sendCurrentGameDataWithNewTurn:newTurn];
}];
}
else
{
NSData *matchData = [NSKeyedArchiver archivedDataWithRootObject:game];
//Game advances to new player, buttons are disabled
if(newTurn)
{
NSLog(@"SENDING NEW TURN");
NSUInteger currentIndex = [gcMatch.participants
indexOfObject:gcMatch.currentParticipant];
GKTurnBasedParticipant *nextParticipant;
nextParticipant = [gcMatch.participants objectAtIndex:
((currentIndex + 1) % [gcMatch.participants count])];
[gcMatch endTurnWithNextParticipants:[NSArray arrayWithObject:nextParticipant] turnTimeout:GC_TURN_TIMEOUT matchData:matchData completionHandler:^(NSError *error) {
NSLog(@"Sent");
if (error) {
NSLog(@"SNT - %@", error);
}
}];
}
else
{
NSLog(@"ONLY UPDATING DATA");
[gcMatch saveCurrentTurnWithMatchData:matchData completionHandler:^(NSError *error) {
NSLog(@"Sent");
if (error) {
NSLog(@"OUD - %@", error);
}
}];
}
}
}
-(void) updateGameDataWithGCMatch
{
//Update whole game data
self.game = [NSKeyedUnarchiver unarchiveObjectWithData:self.gcMatch.matchData];
//Update game ui
...
}
-(void) handleTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive
{
//Check if I got data for the currently active match that options vc forwarded me here, if not do some debug print and return
if(![self.gcMatch.matchID isEqual:match.matchID])
{
//For debugging reasons I skip if i get info for any previous match (other player quit etc)
NSLog(@"GCMatch matchID: %@ match matchID: %@",self.gcMatch.matchID,match.matchID);
return;
}
NSLog(@"Turn event handle");
self.gcMatch = match;
if([match.currentParticipant.playerID isEqualToString: [GKLocalPlayer localPlayer].playerID ])
{
//Disable field buttons
[self setFieldButtonsEnabled:TRUE];
[self turnChangeAnimationFromLeftToRight:FALSE];
}
[self updateGameDataWithGCMatch];
}
गेम सेंटर मनमाने ढंग से लापरवाह हो सकता है। कभी नहीं पता कि यह हमारे नेटवर्किंग के कारण है, या ऐप्पल के पक्ष में कुछ है। –
मुझे पिछले 2-3 हफ्तों के लिए यह अंतराल रहा है। अब यह बदतर या बेहतर हो गया है। क्या मैं आपसे पूछ सकता हूं कि जब आप 2 ऐप पर सैंडबॉक्स खातों के साथ अपने ऐप का परीक्षण करते हैं तो आपके पास ऐसे अंतराल होते हैं। यदि अन्य डेवलपर्स भी इसे प्राप्त कर रहे हैं, तो मैं समाधान की तलाश करना बंद कर दूंगा; जैसा कि यह है, परीक्षण पर जारी रखें। – guenis
जीसी सैंडबॉक्स के साथ काम करते समय मैंने भी महत्वपूर्ण अंतराल का अनुभव किया है। यह कार्य सत्र से कार्य सत्र तक काफी भिन्न होता है। – crgt