| 1 |
#ifndef AWS_MQTT_PRIVATE_REQUEST_RESPONSE_PROTOCOL_ADAPTER_H |
| 2 |
#define AWS_MQTT_PRIVATE_REQUEST_RESPONSE_PROTOCOL_ADAPTER_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/mqtt/exports.h> |
| 10 |
#include <aws/mqtt/mqtt.h> |
| 11 |
|
| 12 |
#include <aws/common/byte_buf.h> |
| 13 |
|
| 14 |
struct aws_allocator; |
| 15 |
struct aws_event_loop; |
| 16 |
struct aws_mqtt_client_connection; |
| 17 |
struct aws_mqtt5_client; |
| 18 |
struct aws_mqtt_rr_incoming_publish_event; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
struct aws_protocol_adapter_subscribe_options { |
| 33 |
struct aws_byte_cursor topic_filter; |
| 34 |
uint32_t ack_timeout_seconds; |
| 35 |
}; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
struct aws_protocol_adapter_unsubscribe_options { |
| 41 |
struct aws_byte_cursor topic_filter; |
| 42 |
uint32_t ack_timeout_seconds; |
| 43 |
}; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
struct aws_protocol_adapter_publish_options { |
| 49 |
struct aws_byte_cursor topic; |
| 50 |
struct aws_byte_cursor payload; |
| 51 |
uint32_t ack_timeout_seconds; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
void (*completion_callback_fn)(int, void *); |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
void *user_data; |
| 63 |
}; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
enum aws_protocol_adapter_subscription_event_type { |
| 69 |
AWS_PASET_SUBSCRIBE, |
| 70 |
AWS_PASET_UNSUBSCRIBE, |
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
struct aws_protocol_adapter_subscription_event { |
| 78 |
struct aws_byte_cursor topic_filter; |
| 79 |
enum aws_protocol_adapter_subscription_event_type event_type; |
| 80 |
int error_code; |
| 81 |
bool retryable; |
| 82 |
}; |
| 83 |
|
| 84 |
enum aws_protocol_adapter_connection_event_type { |
| 85 |
AWS_PACET_CONNECTED, |
| 86 |
AWS_PACET_DISCONNECTED, |
| 87 |
}; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
struct aws_protocol_adapter_connection_event { |
| 93 |
enum aws_protocol_adapter_connection_event_type event_type; |
| 94 |
bool joined_session; |
| 95 |
}; |
| 96 |
|
| 97 |
typedef void(aws_protocol_adapter_subscription_event_fn)( |
| 98 |
const struct aws_protocol_adapter_subscription_event *event, |
| 99 |
void *user_data); |
| 100 |
|
| 101 |
typedef void(aws_protocol_adapter_incoming_publish_fn)( |
| 102 |
const struct aws_mqtt_rr_incoming_publish_event *publish, |
| 103 |
void *user_data); |
| 104 |
|
| 105 |
typedef void(aws_protocol_adapter_terminate_callback_fn)(void *user_data); |
| 106 |
|
| 107 |
typedef void(aws_protocol_adapter_connection_event_fn)( |
| 108 |
const struct aws_protocol_adapter_connection_event *event, |
| 109 |
void *user_data); |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
struct aws_mqtt_protocol_adapter_options { |
| 115 |
aws_protocol_adapter_subscription_event_fn *subscription_event_callback; |
| 116 |
aws_protocol_adapter_incoming_publish_fn *incoming_publish_callback; |
| 117 |
aws_protocol_adapter_terminate_callback_fn *terminate_callback; |
| 118 |
aws_protocol_adapter_connection_event_fn *connection_event_callback; |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
void *user_data; |
| 125 |
}; |
| 126 |
|
| 127 |
struct aws_mqtt_protocol_adapter_vtable { |
| 128 |
|
| 129 |
void (*aws_mqtt_protocol_adapter_destroy_fn)(void *); |
| 130 |
|
| 131 |
int (*aws_mqtt_protocol_adapter_subscribe_fn)(void *, struct aws_protocol_adapter_subscribe_options *); |
| 132 |
|
| 133 |
int (*aws_mqtt_protocol_adapter_unsubscribe_fn)(void *, struct aws_protocol_adapter_unsubscribe_options *); |
| 134 |
|
| 135 |
int (*aws_mqtt_protocol_adapter_publish_fn)(void *, struct aws_protocol_adapter_publish_options *); |
| 136 |
|
| 137 |
bool (*aws_mqtt_protocol_adapter_is_connected_fn)(void *); |
| 138 |
|
| 139 |
struct aws_event_loop *(*aws_mqtt_protocol_adapter_get_event_loop_fn)(void *); |
| 140 |
}; |
| 141 |
|
| 142 |
struct aws_mqtt_protocol_adapter { |
| 143 |
const struct aws_mqtt_protocol_adapter_vtable *vtable; |
| 144 |
void *impl; |
| 145 |
}; |
| 146 |
|
| 147 |
AWS_EXTERN_C_BEGIN |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
AWS_MQTT_API struct aws_mqtt_protocol_adapter *aws_mqtt_protocol_adapter_new_from_311( |
| 153 |
struct aws_allocator *allocator, |
| 154 |
struct aws_mqtt_protocol_adapter_options *options, |
| 155 |
struct aws_mqtt_client_connection *connection); |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
AWS_MQTT_API struct aws_mqtt_protocol_adapter *aws_mqtt_protocol_adapter_new_from_5( |
| 161 |
struct aws_allocator *allocator, |
| 162 |
struct aws_mqtt_protocol_adapter_options *options, |
| 163 |
struct aws_mqtt5_client *client); |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
AWS_MQTT_API void aws_mqtt_protocol_adapter_destroy(struct aws_mqtt_protocol_adapter *adapter); |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
AWS_MQTT_API int aws_mqtt_protocol_adapter_subscribe( |
| 175 |
struct aws_mqtt_protocol_adapter *adapter, |
| 176 |
struct aws_protocol_adapter_subscribe_options *options); |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
AWS_MQTT_API int aws_mqtt_protocol_adapter_unsubscribe( |
| 182 |
struct aws_mqtt_protocol_adapter *adapter, |
| 183 |
struct aws_protocol_adapter_unsubscribe_options *options); |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
AWS_MQTT_API int aws_mqtt_protocol_adapter_publish( |
| 189 |
struct aws_mqtt_protocol_adapter *adapter, |
| 190 |
struct aws_protocol_adapter_publish_options *options); |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
AWS_MQTT_API bool aws_mqtt_protocol_adapter_is_connected(struct aws_mqtt_protocol_adapter *adapter); |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
AWS_MQTT_API struct aws_event_loop *aws_mqtt_protocol_adapter_get_event_loop(struct aws_mqtt_protocol_adapter *adapter); |
| 202 |
|
| 203 |
AWS_MQTT_API const char *aws_protocol_adapter_subscription_event_type_to_c_str( |
| 204 |
enum aws_protocol_adapter_subscription_event_type type); |
| 205 |
|
| 206 |
AWS_MQTT_API const char *aws_protocol_adapter_connection_event_type_to_c_str( |
| 207 |
enum aws_protocol_adapter_connection_event_type type); |
| 208 |
|
| 209 |
AWS_EXTERN_C_END |
| 210 |
|
| 211 |
#endif |