Add an input processing function for a remote node
int PtAppAddInputRemote( PtAppContext_t app_context, int nd, pid_t pid, PtInputCallbackProc_t input_func, void *data );
If you specify a pid of 0, the input function is called for every non-Photon event message that's received, but only if there's no input function that catches messages from the sending pid specifically. If pid is 0, you must specify a nd of 0 as well. Your input handler will get all messages from processes on any node, and all pulses (except those that were already handled and returned Pt_END or Pt_HALT).
This routine adds a function to a PtMainLoop() input-event processing chain for a process running on a remote node.
|To attach an input handling function to a process on your node, use PtAppAddInput().|
The input_func argument points to the input function to be invoked. The function takes this form:
int (*input_func)(void *data, int rcvid, void *message, size_t size);
The arguments are:
For a Photon pulse, it's the value from the pulse structure (see _pulse in the QNX Neutrino Library Reference).
If you application knows the maximum size of a message that can be possibly sent to it, you can use PtResizeEventMsg() to ensure that the buffer is large enough.
|Receiving a large Photon event may make the buffer bigger than was established by PtResizeEventMsg().|
You can declare the function to be of type PtInputCallbackProcF_t to take advantage of the compiler's type-checking.
|If the input function changes the display, it should call PtFlush() to make sure the display is updated.|
The input function must return one of the following:
PtAppAddInputRemote() and name_attach() both try to create a channel with _NTO_CHF_COID_DISCONNECT and _NTO_CHF_DISCONNECT set (see the QNX Neutrino Library Reference). If your application calls both functions, you need to let Photon use the same channel as name_attach(). To do this, call these functions in this order:
If you want to create a separate channel for Photon, it doesn't matter whether you create it and give it to PhChannelAttach() before or after calling name_attach(). But keep in mind that since certain mechanisms in Photon library expect the Photon channel to have the two DISCONNECT flags, they might not work properly if it doesn't. One such mechanism is the detection of broken connections (see PtConnectionClientSetError() and PtConnectionServerSetError()) and anything that relies on it.
A pointer to a PtInputId_t structure that uniquely identifies the specified input function for the given application context. If an error occurs, the function returns NULL.
PhChannelAttach(), PtAppAddInput(), PtAppCreatePulse(), PtAppRemoveInput(), PtGetRcvidPidNd(), PtMainLoop(), PtResizeEventMsg()
Interprocess Communication chapter of the Photon Programmer's Guide
_pulse, MsgReceive(), and name_attach() in the QNX Neutrino Library Reference