Previous Book Contents Book Index Next

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


NSpMessageHandlerProcPtr

You can define a function of this type for NetSprocket to call asynchronously when a message arrives.

typedef pascal Boolean (*NSpMessageHandlerProcPtr) (
	NSpGameReference inGame,
	NSpMessageHeader *inMessage,
	void* inContext);
inGame
An opaque reference to the game object that received the message.
inMessage
A pointer to the message.
inContext
The context pointer you passed in when you installed the handler.
DESCRIPTION
Your function must handle the message and return as quickly as possible. You should not free the message, as it will be automatically freed when your function returns. If you return true, then NetSprocket will put the message back into the incoming message queue. When you call the NSpMessage_Get function you will receive the message again. If you return false, the message will be deleted when your function returns. As an example, if you receive a message and you want to change part of the message or add to it, you can make a note in the message and then receive it again with the note added to the message. You can also use this as a mechanism for time stamping messages and only act on the latest messages.

You do not need to define a function of this type if you use NetSprocket in the normal event-loop mode.

Your handler must obey all the rules of interrupt-safe functions.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996