objective c - (GKMatch GKVoiceChat) - both Players get disconnected after didFindMatch is called -


i'm trying achieve voicechat among 2 connected players using gkmatch object. players authenticated , i'm able create match using gkmatchmakerviewcontroller.

the issue when receive gkmatch object via delegate callback matchmakerviewcontroller:didfindmatch:, setup audiosession , voicechat object. after method returned callback in gkmatch's delegate match:player:didchangestate:

here's how i'm creating audiosession , voicechat in didfindmatch callback:

- (void)matchmakerviewcontroller:(gkmatchmakerviewcontroller *)viewcontroller didfindmatch:(gkmatch *)match {      [viewcontroller dismissviewcontrolleranimated:yes completion:nil];      self.match = match;     match.delegate = self;      if (!_matchstarted && match.expectedplayercount == 0)     {         nserror *err = nil;         avaudiosession *audiosession = [avaudiosession sharedinstance];         [audiosession setcategory:avaudiosessioncategoryplayandrecord error:&err];         [audiosession setactive: yes error:&err];          if (err)         {             nslog(@"%@",err.localizeddescription);         }         self.teamchannel = [[match voicechatwithname:@"redteam"] retain];          _teamchannel.volume = 1.0f;         _teamchannel.active = yes;          [_teamchannel start];          _teamchannel.playerstateupdatehandler = ^(nsstring *playerid, gkvoicechatplayerstate state) {             switch (state)             {                 case gkvoicechatplayerspeaking:                     nslog(@"speaking...");                     break;                 case gkvoicechatplayersilent:                     break;                     case gkvoicechatplayerconnected:                     nslog(@"connected.");                     break;                     case gkvoicechatplayerconnecting:                     nslog(@"connecting..");                     break;                     case gkvoicechatplayerdisconnected:                     nslog(@"disconnected.");                     break;             }         };     } } 

i never call in playerstateupdatehandler. disconnected call in following function: `- (void)match:(gkmatch *)match player:(nsstring *)playerid didchangestate:(gkplayerconnectionstate)state { if (_match != match) return;

switch (state) {     case gkplayerstateconnected:         nslog(@"player connected!");         break;     case gkplayerstatedisconnected:         nslog(@"player disconnected!");         _matchstarted = no;         break;     case gkplayerstateunknown:         nslog(@"player stage unknown.");         break; } 

}`

question:-

i'm unable hear audio on end, missing ? i've been trying 3 days now, , (as side question) i'm not sure second player. as, when there's match didfindmatch on 1 of device's , there's no call-back on other device. need send message on other device ? match ?

a quick appreciated.

it sounds inviting player rather auto matching one, if case didfindmatch called on hosting device. client finds out in invitehandler

[gkmatchmaker sharedmatchmaker].invitehandler = ^(gkinvite *acceptedinvite, nsarray *playerstoinvite)  {     if (acceptedinvite)     {         gkmatchmakerviewcontroller *mmvc = [[gkmatchmakerviewcontroller alloc] initwithinvite:acceptedinvite];         mmvc.matchmakerdelegate = self;          // client connection stuff here     }     else if (playerstoinvite)     {         gkmatchrequest *request = [[gkmatchrequest alloc] init];         request.minplayers = 2;         request.maxplayers = 2;         request.playerstoinvite = playerstoinvite;          gkmatchmakerviewcontroller *mmvc = [[gkmatchmakerviewcontroller alloc] initwithmatchrequest:request];         mmvc.matchmakerdelegate = self;          [pviewcontroller presentviewcontroller:mmvc animated:yes completion:nil];     } }; 

if auto matching game both players receive callback inside [[gkmatchmaker sharedmatchmaker] findmatchforrequest:request withcompletionhandler:^(gkmatch *match, nserror *error)

 [[gkmatchmaker sharedmatchmaker] findmatchforrequest:request withcompletionhandler:^(gkmatch *match, nserror *error)  {     if (error != nil)     {         nslog(@"multiplayer match request failed: %@", error.localizeddescription);     }     else if (match != nil)     {         self.m_pmatchobject = [match retain];     } }]; 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -