Previous Book Contents Book Index Next

Inside Macintosh: Apple Game Sprockets Guide /
Chapter 4 - NetSprocket / NetSprocket Reference
NetSprocket Functions / Sending and Receiving Messages


NSpMessage_Get

You can use the NSpMessage_Get function to receive messages that have been delivered to your game. You can use this function to retrieve and process messages whether you are a player in the game or you are hosting a game.

NSpMessageHeader *NSpMessage_Get (
	NSpGameReference inGame);
inGame
An opaque reference to your game object.
function result
A pointer to your incoming message data structure.
DESCRIPTION
Once game play has begun, you will probably want to call this function each time you pass through your game loop to process all network messages as quickly and efficiently as possible.

NSpMessage_Get returns NULL if there are no messages pending. If a message has been received, NetSprocket will return a pointer to a message structure.

NSpMessage_Get returns a pointer to an NSpMessageHeader-based structure that is allocated by NetSprocket. You should call NSpMessage_Release to release the memory back to NetSprocket when you're done with the message. Failure to release memory in a timely fashion will limit NetSprocket's ability to handle more incoming messages. NSpMessage_Get and NSpMessage_Release are a more efficient method of message processing than the time-consuming process of copying incoming messages from NetSprocket into your application's message buffer.

Error messages such as kNSpError may also be returned by NetSprocket.

You should call NSpMessage_Get as frequently as you can to get messages that have been sent to your player.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996