GEOS SDK TechDocs
|
|
6.3 Messages Across an IACP Link
|
6.5 Being a Server
Any object can register as a client for an IACP server list. When an object is a client, it can send messages to the server list, which will pass them along to the servers for that list.
IACPConnect(), IACPCreateDefaultLaunchBlock()
To register as a client for a list, call the routine
IACPConnect()
. When you call this routine, you specify which server list you are interested in. If there is no such server list running, you can instruct the kernel to start up the server list, as well as one of the default applications for that list.
IACPConnect()
is passed five arguments:
GeodeToken
of the list for which you want to register.
IACPConnectFlags
. The following flags are available:
AppLaunchBlock
, with the ALB
_appMode
field set to MSG_GEN_PROCESS_OPEN_APPLICATION; you must also set IACPCF_SERVER_MODE to IACPSM_USER_INTERACTIBLE.
IACPServerMode
enumerated type. This type specifies how the client expects the server to behave. Currently, only two types are supported:
MemHandle
of an
AppLaunchBlock
. If the server you specify is not running, GEOS will launch the application specified by the
AppLaunchBlock
. If you pass a null
MemHandle
, GEOS will return an error if no server is running.
IACPConnect()
will write the number of servers on the list to that word.
IACPConnect()
returns a word-sized
IACPConnection
token. You will need to pass that token when you call another IACP routine to use the connection. It will also return the number of server objects on the list; it returns this value by writing it to the address indicated by the pointer passed.
If the server list you indicate is not currently running, IACP may do one of two different things. If you pass a null handle as the third argument,
IACPConnect()
will fail. It will return the error value IACP_NO_CONNECTION, and indicate that there are no servers on the specified list.
If you pass an
AppLaunchBlock
,
IACPConnect()
will examine that launch block to see what application should be launched to act as a server. The
AppLaunchBlock
should specify the location and name of the application to open. If the ALB
_appRef.AIR_diskHandle
field is non-zero,
IACPConnect()
will look in the specified disk or standard path for an application with the right
GeodeToken
; otherwise, it will look in the standard places for an application.
Note that if you pass a launch block to
IACPConnect()
, you may
not
alter or free it afterwards. If the application is created, the block you pass will be its launch block; if not, the kernel will free the block automatically. In any event, the caller no longer has access to the block.
If
IACPConnect()
launches an application, the caller will block until that application has been created and registers for the server list. If the application does not register for that list, the caller will never unblock. You must therefore make sure that you are launching the right application for the list. Note that every application object will automatically register for the server list which shares its token.
To create a launch block, you should call
IACPCreateDefaultLaunchBlock()
. This routine is passed a single argument, which specifies how the application will be opened. That argument must be MSG_GEN_PROCESS_OPEN_APPLICATION (the application will be opened as a standard, user-interactible application); MSG_GEN_PROCESS_OPEN_ENGINE (the application will be opened in engine mode, i.e. with no user interface); or MSG_GEN_PROCESS_OPEN_CUSTOM (which has an application-specified meaning).
IACPCreateDefaultLaunchBlock()
allocates a launch block and sets up its fields appropriately. As created, the launch block will have the following characteristics:
_diskHandle
field) will be SP_DOCUMENT.
_appRef.
AIR
_diskHandle
will be zero);
IACPConnect()
will attempt to find the application on its own.
_dataFile
will be blank).
_genParent
will be null).
_extraData
will be zero).
_userLoadAckOutput
and
ALB
_userLoadAckMessage
will be null.)
IACPCreateDefaultLaunchBlock()
returns the handle of the newly-created launch block. Once the block is created, you can alter any of its fields before passing the launch block to
IACPConnect()
. (Once you pass the launch block to
IACPConnect()
, you may not alter it any more.)
Often a client will want the server to open a specific document. For example, if a desktop-manager is implementing a "print-file" command, it will need to open a server application, instruct it to open the file to be printed, and then instruct it to print the file. To make the server open a document, pass the document's name in ALB
_dataFile
. The server will open the file when you register, and close it when you unregister.
IACPShutdown(), IACPShutdownAll()
If an application no longer needs to interact with a particular server list, it should call
IACPShutdown()
. This routine is also used by servers which wish to remove themselves from a server list. This section describes how the routine is used by clients; Being a Server
describes how it is used by servers.
The routine is passed two arguments:
IACPConnection
token for the link which is being shut down.
IACPShutdown()
sends MSG_META_IACP_LOST_CONNECTION to all objects on the other side of the link; that is, if a client calls
IACPShutdown()
, all servers on the list will be sent this message.
IACPShutdownAll()
closes all IACP links for the application which calls it. The Application object automatically calls this routine when the application is exiting.
GEOS SDK TechDocs
|
|
6.3 Messages Across an IACP Link
|
6.5 Being a Server