00001
00026 #ifndef MESSAGING_H_
00027 #define MESSAGING_H_
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033 #include <stdlib.h>
00034
00035 #ifdef __cplusplus
00036
00037 #include <stdint.h>
00038 #else
00039 #include <stdint.h>
00040 #endif
00041
00042 struct array;
00043 struct datum;
00044
00047 typedef enum {
00048 NULL_CONTENT = 0,
00049 BYTE_CONTENT = 1,
00050 INT8_CONTENT = 2,
00051 UINT8_CONTENT = 3,
00052 INT16_CONTENT = 4,
00053 UINT16_CONTENT = 5,
00054 INT32_CONTENT = 6,
00055 UINT32_CONTENT = 7,
00056 INT64_CONTENT = 8,
00057 UINT64_CONTENT = 9,
00058 FLOAT_CONTENT = 10,
00059 DOUBLE_CONTENT = 11
00060 } Message_content_type;
00061
00067 typedef struct connection Connection;
00068
00078 typedef struct channel Channel;
00079
00081 typedef struct data {
00082
00084 int length;
00085
00087 Message_content_type type;
00088
00090 void const *content;
00091 } Data;
00092
00095 typedef struct message {
00097 int length;
00098
00100 Data *fields;
00101 } Message;
00102
00113 typedef struct messaging_controller {
00114
00127 void (*poll)(Connection *connection[], int count, int timeout);
00128
00130 void (*send_immediate)(Channel *channel, Message *message);
00131
00142 int (*process_messages)(Connection *connection, short limit);
00143 } Messaging_Controller;
00144
00151 typedef void (*callback)(Channel *channel, Message *mesg, void *state);
00152
00160 typedef struct messaging {
00161
00167 Connection *(*open_connection)(void);
00168
00173 Channel *(*open_channel)(Connection *connection, const char * channel_name);
00174
00178 void (*close_connection)(Connection *connection);
00179
00183 void (*close_channel)(Channel *channel);
00184
00189 void (*send)(Channel *channel, Message *message);
00190
00192 void (*unsubscribe)(Channel *channel);
00193
00195 void (*subscribe)(Channel *channel, callback fp, void *state);
00196
00203 Messaging_Controller *(*get_controller)();
00204
00205 } Messaging;
00206
00215 #ifdef __cplusplus
00216 }
00217 #endif
00218
00219 #endif