GameKit: GKSession manual

Posted by mongeta on Stack Overflow See other posts from Stack Overflow or by mongeta
Published on 2010-02-19T14:11:32Z Indexed on 2010/03/29 5:03 UTC
Read the original article Hit count: 697

Filed under:
|

Hello,

I want to connect two devices using the GKSession, starting one as a server and the other one as a client. Using this configuration I can't use the GKPeerPickerController.

I'm having problems for connecting the two devices:

  • Using only bluetooth: impossible
  • using WiFi: at least there are some data exchange between the devices but no successfully conection.

In the interface file I have the

GKSessionDelegate
GKSession *session;

In the implementation, I start the server using this code:

session = [[GKSession alloc] initWithSessionID:@"iFood"  displayName:nil sessionMode:GKSessionModeClient];
session.delegate = self;
session.available = YES;

The client starts using this code:

session = [[GKSession alloc] initWithSessionID:@"iFood"  displayName:nil sessionMode:GKSessionModeServer];
session.delegate = self;
session.available = YES;

How I can force the use of Bluetooth instead of the WiFi ?

Also I have implemented those calls:

-(void)session:(GKSession *)session didReceiveConnectionRequestFromPeer:(NSString *)peerID {
NSLog(@"Someone is trying to connect"); 
}

- (BOOL)acceptConnectionFromPeer:(NSString *)peerID error:(NSError **)error {
NSLog(@"acceptConnectionFromPeer");
}

When I start, I get this into the debugger:

Listening on port 50775
2010-02-19 14:55:02.547 iFood[3009:5103] handleEvents started (2)

And when the other device starts to find, I get this:

~ DNSServiceBrowse callback: Ref=187f70, Flags=2, IFIndex=2 (name=[en0]), ErrorType=0 name=00eGs1R1A..Only by Audi regtype=_2c3mugr67ej6j7._udp. domain=local.
~ DNSServiceQueryRecord callback: Ref=17bd40, Flags=2, IFIndex=2 (name=[en0]), ErrorType=0 fullname=00eGs1R1A\.\.Only\032by\032Audi._2c3mugr67ej6j7._udp.local. rrtype=16 rrclass=1 rdlen=18 ttl=4500
** peer 1527211048: oldbusy=0, newbusy=0
~ DNSServiceBrowse callback: Ref=187f70, Flags=2, IFIndex=-3 (name=[]), ErrorType=0 name=00eGs1R1A..Only by Audi regtype=_2c3mugr67ej6j7._udp. domain=local.
GKPeer[186960] 1527211048 service count old=1 new=2
~ DNSServiceQueryRecord callback: Ref=17bd40, Flags=2, IFIndex=-3 (name=[]), ErrorType=0 fullname=00egs1r1a\.\.only\032by\032audi._2c3mugr67ej6j7._udp.local. rrtype=16 rrclass=1 rdlen=18 ttl=7200
** peer 1527211048: oldbusy=0, newbusy=0
~ DNSServiceBrowse callback: Ref=187f70, Flags=2, IFIndex=-3 (name=[]), ErrorType=0 name=00TF5kc1A..Only by Audi regtype=_2c3mugr67ej6j7._udp. domain=local.
~ DNSServiceQueryRecord callback: Ref=188320, Flags=2, IFIndex=-3 (name=[]), ErrorType=0 fullname=00tf5kc1a\.\.only\032by\032audi._2c3mugr67ej6j7._udp.local. rrtype=16 rrclass=1 rdlen=18 ttl=7200
** peer 1723356125: oldbusy=0, newbusy=0
~ DNSServiceQueryRecord callback: Ref=188320, Flags=2, IFIndex=2 (name=[en0]), ErrorType=0 fullname=00TF5kc1A\.\.Only\032by\032Audi._2c3mugr67ej6j7._udp.local. rrtype=16 rrclass=1 rdlen=18 ttl=4500
** peer 1723356125: oldbusy=0, newbusy=0

What I'm missing here ?

I'm sure that both devices have bluetooth enabled and connected into the same WiFi.

thanks,

r.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about gamekit