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 me开发者_运维问答thod. How do you know whether this is for example a score or health points?
How do you differentiate what data is received?
Thanks.
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
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.'
精彩评论