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
18 #include "gras/transport.h"
19 #include "gras/datadesc.h"
23 /* msgtype declaration and retrival */
24 typedef struct s_gras_msgtype *gras_msgtype_t;
26 void gras_msgtype_declare (const char *name,
27 gras_datadesc_type_t payload);
28 void gras_msgtype_declare_v(const char *name,
30 gras_datadesc_type_t payload);
32 gras_msgtype_t gras_msgtype_by_name (const char *name);
33 gras_msgtype_t gras_msgtype_by_namev(const char *name,
38 * @msg: The message itself
39 * @Returns: true if the message was consumed by the callback.
41 * Type of message callback functions. Once a such a function is registered to
42 * handle messages of a given type with RegisterCallback(), it will be called
43 * each time such a message incomes.
45 * If the callback accepts the message, it should free it after use.
47 typedef int (*gras_cb_t)(gras_socket_t expeditor,
49 void gras_cb_register (gras_msgtype_t msgtype,
51 void gras_cb_unregister(gras_msgtype_t msgtype,
54 gras_error_t gras_msg_send(gras_socket_t sock,
55 gras_msgtype_t msgtype,
57 gras_error_t gras_msg_wait(double timeout,
58 gras_msgtype_t msgt_want,
59 gras_socket_t *expeditor,
61 gras_error_t gras_msg_handle(double timeOut);
66 #endif /* GRAS_MSG_H */