IPCPortHandlerBase (open)
This objecttype is meant as a base for a message-handling script, and tries to abstract away the waiting on, receiving of and sending of messages as much as possible.
How to use it:
Open a listening port (eg using CreateIPCPort). Create an object based on the porthandlerbase, and give the port as argument. Call the Run member.
Messages will be dispatched to the OnMessage member. When processing just one message at a time, the reply can be sent by just returning the appropriate return value.
If you waiting loop needs to wait on other handles, or you need timeouts, you can override some other functions, to implement those.
In flat_responses mode, exceptions are given back as cell __exception Cells: what (string), trace (record array)
Syntax
LOADLIB "wh::ipc.whlib";
OBJECTTYPE IPCPortHandlerBase
Constructor
- MACRO NEW(OBJECT port)
Creates a new port handler
Properties
- PROPERTY flat_responses
If TRUE, no extra level [ success := TRUE, reply := ... ] is set in returned messages, and exceptions are integrated in messages (in cell __exception)
- PROPERTY listenport
IPC Port this handler listens on
Functions
- MACRO AddListeningPort(OBJECT port)
Adds extra listening port
- INTEGER ARRAY FUNCTION GetDefaultWaitHandles()
Returns list of internal handles the porthandler needs to wait on. Do NOT override to wait on more handles, override WaitForEvent instead.
- MACRO Run()
Runs the handling loop. Will not return.