for connected embedded systems
![]() |
![]() |
![]() |
![]() |
PtConnectionAddEventHandlers()
Add a set of server event handlers to a client connection object
Synopsis:
int PtConnectionAddEventHandlers(
PtConnectionClient_t *connection,
PtConnectionEventHandler_t const *handlers,
unsigned nhandlers );
Library:
ph
Description:
This function adds a set of server event handlers to a client connection object. The handlers[] argument points to an array of PtConnectionEventHandler_t structures:
typedef int PtConnectionEventFunc_t(
PtConnectionClient_t *connection, void *user_data,
unsigned long type, void const *msg, unsigned len );
typedef struct Pt_connection_event_handler {
unsigned long type;
PtConnectionEventFunc_t *fun;
} PtConnectionEventHandler_t;
The array must be sorted with respect to the type field; it also must not be destroyed or modified as long as the connection object using it exists.
If you add multiple tables to a connection object, they're searched in the reverse order: a call to PtConnectionAddEventHandlers() can override handlers that were attached by a previous call. An event handler should return Pt_END to "consume" the event, or Pt_CONTINUE to continue the search.
A special value of zero in the type field means "any type." When a notification from the server arrives, all the tables are searched for an exact match on the type, and if the event isn't consumed, the tables are searched again for a handler with type 0.
Returns:
- 0
- Success.
- -1
- An error occurred; errno is set.
Classification:
Photon
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
See also:
PtConnectionAddMsgHandlers(), PtConnectionNotify(), PtConnectionReply(), PtConnectionReplymx(), PtConnectionResizeEventBuffer()
"Connections" in the Interprocess Communication chapter of the Photon Programmer's Guide
![]() |
![]() |
![]() |
![]() |

![[Previous]](../prev.gif)
![[Contents]](../contents.gif)
![[Index]](../keyword_index.gif)
![[Next]](../next.gif)