Apple AppleShare 3.0 File Server Controls User Manual
Page 29

scPB: SCParamBlockRec;
BEGIN
scPB.serverEventPB.scCode := SCGetServerEventProc;
MySCGetServerEventProc := SyncServerDispatch(@scPB);
theSEQHdrPtr := QHdrPtr(scPB.serverEventPB.scSEQEntryPtr);
END;
_____________________________________________________________________________
CHAPTER 2
_____________________________________________________________________________
SERVER EVENT HANDLING
The chapter explains how your applications can monitor server events and
respond to these events by using server event handlers. A sample handler is
included to show how you might implement server event handlers in your own
server additions.
The AppleShare File Server 3.0 server event mechanism enables programs (and
INITs) to monitor and respond to a file server's activities. This mechanism
allows developers to create programs that work in concert with file servers
to extend the services provided by the servers. For example, server
statistics reporting, audit trailing, and extended security could all be
added to existing file services.
The server event mechanism comprises two parts: the server event handler and
the application program. The server event handler is a server-addition
procedure, installed in the server by the SCInstallServerEventProc server
control call. The server calls the server event handler whenever a server
event occurs. A server event is a condition or operation occurring in the
file server, such as the receipt of an AFP or server control call, the
mounting of a volume by a user, or a client disconnect. When a server
notifies the server event handler of an event, the handler passes information
to the application program so that the program can respond to the event. An
application typically allocates a buffer and passes the buffer's address to
the server event handler when the handler is installed. The server event
handler fills the buffer asynchronously, while the installing program
analyzes the buffer's contents from the application's event loop.
Using server events
To monitor server events from your server addition, you must first install a
server event handler in the file server. You install a server event handler
from your program by issuing the SCInstallServerEventProc server control
call, as described in "Using Server Event Handlers" in Chapter 1. Installing
a server event handler is very similar to the process of installing the
AppleTalk Transition Queue. (For information about installing an entry into
the AppleTalk Transition Queue, see Inside Macintosh, Volume VI.)
Once the server event handler is installed, it gains control whenever one of
the specified server events occurs. When a server event occurs, the server
determines whether any server event handlers are installed. For each
installed handler, the server checks the SEeventFlag in the tSEQEntry record