Josh Kahane
Josh Kahane

Reputation: 17160

GameCenter - Receive Multiple Bits of Data?

So I have sending and receiving data in GameCenter on my iphone working well, but when you receive data you get 'data' from the method. How do you know whether this is for example a score or health points?

How do you differentiate what data is received?

Thanks.

Upvotes: 0

Views: 130

Answers (2)

HBu
HBu

Reputation: 559

Look at SessionManager.m in the GKRocket example in the docs. Especially the implementations of

-(void) sendPacket:(NSData*)data ofType:(PacketType)type

and

- (void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession:(GKSession *)session context:(void *)context

Upvotes: 1

hungrybutterfly
hungrybutterfly

Reputation: 46

As explained by Apple's docs...

'Your message format should include a way to differentiate between different kinds of messages. For example, you might create an enumerated type that identifies different kinds of messages. The first bytes in every message would start with this enumerated type.'

Upvotes: 0

Related Questions