Multipeer Connectivity: recebendo um convite aceito (usando o navegador embutido VC)
eu estou tentandosiga a palestra da WWDC para aprender sobre o framework MultipeerConnectivity. Depois de muitas falsas partidas, o (s) navegador (es) mostra os pares e os convites são emitidos.
Mas quando eu pressiono "Aceitar" no dispositivo de mesmo nível, o navegador continua mostrando "Conectando" sem fim. Eu pensei que oMCBrowserViewController
cuidei da lógica e pude relaxar até que o usuário do navegador pressionou Cancelar ou Concluído, e o método delegado disparou. Aposto que é algo óbvio, mas está me escapando.
Aqui está o que eu espero que seja o código relevante. Eu tenho isso no AppDelegate. As instruções NSLog nos vários métodos delegados são chamadas como seria de esperar - exceto a que está embrowserViewControllerDidFinish:
claro.
Tenha em mente que o navegador e os convites aparecem,alguma coisa está certo!
No @interface ...
@property (strong, nonatomic) MCSession *theSession;
@property (strong, nonatomic) MCAdvertiserAssistant *assistant;
@property (strong, nonatomic) MCBrowserViewController *browserVC;
Na @implementation
static NSString* const kServiceType = @"eeps-multi";
// called from viewDidAppear in the main ViewController
-(void) startSession
{
if (!self.theSession) {
UIDevice *thisDevice = [UIDevice currentDevice];
MCPeerID *aPeerID = [[ MCPeerID alloc ] initWithDisplayName: thisDevice.name];
self.theSession = [[ MCSession alloc ] initWithPeer: aPeerID ];
self.theSession.delegate = self;
} else {
NSLog(@"Session init skipped -- already exists");
}
}
// called from viewDidAppear in the main ViewController
- (void) startAdvertising
{
if (!self.assistant) {
self.assistant = [[MCAdvertiserAssistant alloc] initWithServiceType:kServiceType
discoveryInfo:nil
session:self.theSession ];
self.assistant.delegate = self;
[ self.assistant start ];
} else {
NSLog(@"Advertiser init skipped -- already exists");
}
}
// called from the main ViewController in response to a button press
- (void) startBrowsing
{
if (!self.browserVC){
self.browserVC = [[MCBrowserViewController alloc] initWithServiceType:kServiceType
session:self.theSession];
self.browserVC.delegate = self;
} else {
NSLog(@"Browser VC init skipped -- already exists");
}
[ self.window.rootViewController presentViewController:self.browserVC animated:YES completion:nil];
}
Desde já, obrigado!