ios - GKSession - kill and renew session -



ios - GKSession - kill and renew session -

in order read new display name of peer need kill , renew gksession. setting nil , initiate anew not work. in code below, nslog in for-loop show available peers not called (there's no error message):

-(ibaction) btnrefresh:(id) sender { self.currentsession = nil; self.currentsession = [[gksession alloc] initwithsessionid:@"anything" displayname:name sessionmode:gksessionmodepeer]; self.currentsession.delegate = self; self.currentsession.available = yes; self.currentsession.disconnecttimeout = 0; [self.currentsession setdatareceivehandler:self withcontext:nil]; peerlistavailable = [[nsmutablearray alloc] initwitharray:[currentsession peerswithconnectionstate:gkpeerstateavailable]]; (nsstring *peer in peerlistavailable) { nslog(@"found available peer; checking name , id... %@, %@",[currentsession displaynameforpeer:peer], peer); }

what wrong setting currentsession nil , initiate anew? maybe know of way renew gksession? much in advance.

the next methods illustrate gksession setup , teardown:

- (void)setupsession { gksession = [[gksession alloc] initwithsessionid:nil displayname:nil sessionmode:gksessionmodepeer]; gksession.delegate = self; gksession.disconnecttimeout = 5; gksession.available = yes; } - (void)teardownsession { gksession.available = no; [gksession disconnectfromallpeers]; }

if you're interested in delving deeper, take @ gksessionp2p, demo app illustrates ad-hoc networking features of gksession. app both advertises on local network , automatically connects available peers, establishing peer-to-peer network.

ios bluetooth gksession

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -