3 /* messaging - high level communication (send/receive messages) */
5 /* module's public interface exported to end user. */
7 /* Authors: Martin Quinson */
8 /* Copyright (C) 2003, 2004 Martin Quinson. */
10 /* This program is free software; you can redistribute it and/or modify it
11 under the terms of the license (GNU LGPL) which comes with this package. */
14 #ifndef GRAS_MESSAGES_H
15 #define GRAS_MESSAGES_H
17 /*! C++ users need love */
20 # define BEGIN_DECL extern "C" {
26 /*! C++ users need love */
34 /* End of cruft for C++ */
38 /* msgtype declaration and retrival */
39 typedef struct s_gras_msgtype gras_msgtype_t;
41 gras_error_t gras_msgtype_declare (const char *name,
42 gras_datadesc_type_t *payload,
43 gras_msgtype_t **dst);
44 gras_error_t gras_msgtype_declare_v(const char *name,
46 gras_datadesc_type_t *payload,
47 gras_msgtype_t **dst);
49 gras_error_t gras_msgtype_by_name (const char *name,
50 gras_msgtype_t **dst);
51 gras_error_t gras_msgtype_by_namev(const char *name,
53 gras_msgtype_t **dst);
58 * @msg: The message itself
59 * @Returns: true if the message was consumed by the callback.
61 * Type of message callback functions. Once a such a function is registered to
62 * handle messages of a given type with RegisterCallback(), it will be called
63 * each time such a message incomes.
65 * If the callback accepts the message, it should free it after use.
67 typedef int (*gras_cb_t)(gras_socket_t *expeditor,
69 gras_error_t gras_cb_register (gras_msgtype_t *msgtype,
71 void gras_cb_unregister(gras_msgtype_t *msgtype,
74 gras_error_t gras_msg_send(gras_socket_t *sock,
75 gras_msgtype_t *msgtype,
77 gras_error_t gras_msg_wait(double timeout,
78 gras_msgtype_t *msgt_want,
79 gras_socket_t **expeditor,
81 gras_error_t gras_msg_handle(double timeOut);
86 #endif /* GRAS_MSG_H */