diff options
| author | yangwei <[email protected]> | 2024-07-16 18:24:23 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2024-07-17 11:28:35 +0800 |
| commit | 161aa7da1e82d939ba09f8dc211ffc5f216f963b (patch) | |
| tree | ac116d4baff4a6580d0d4c57d07d84eed5199449 /include | |
| parent | cc862437769735aa5ea31f5b875ea8e25afed726 (diff) | |
🦄 refactor(packet mq & exdata): backport packet mq & exdata
Diffstat (limited to 'include')
| -rw-r--r-- | include/stellar/packet_exdata.h | 8 | ||||
| -rw-r--r-- | include/stellar/packet_mq.h | 22 |
2 files changed, 30 insertions, 0 deletions
diff --git a/include/stellar/packet_exdata.h b/include/stellar/packet_exdata.h new file mode 100644 index 0000000..7620eae --- /dev/null +++ b/include/stellar/packet_exdata.h @@ -0,0 +1,8 @@ +#pragma once + +#include "stellar.h" + +typedef void packet_exdata_free(struct packet *pkt, int idx, void *ex_ptr, void *arg); +int stellar_packet_exdata_new_index(struct stellar *st, const char *name, packet_exdata_free *free_func,void *arg); +int packet_exdata_set(struct packet *pkt, int idx, void *ex_ptr); +void *packet_exdata_get(struct packet *pkt, int idx);
\ No newline at end of file diff --git a/include/stellar/packet_mq.h b/include/stellar/packet_mq.h new file mode 100644 index 0000000..94bb39b --- /dev/null +++ b/include/stellar/packet_mq.h @@ -0,0 +1,22 @@ +#pragma once + +#include "stellar.h" + +//session mq +typedef void packet_msg_free_cb_func(struct packet *pkt, void *msg, void *msg_free_arg); +typedef void on_packet_msg_cb_func(struct packet *pkt, int topic_id, const void *msg, void *plugin_env); + +//return topic_id +int stellar_packet_mq_create_topic(struct stellar *st, const char *topic_name, packet_msg_free_cb_func *msg_free_cb, void *msg_free_arg); + +int stellar_packet_mq_get_topic_id(struct stellar *st, const char *topic_name); + +int stellar_packet_mq_update_topic(struct stellar *st, int topic_id, packet_msg_free_cb_func *msg_free_cb, void *msg_free_arg); + +int stellar_packet_mq_destroy_topic(struct stellar *st, int topic_id); + +//return 0 if success, otherwise return -1. +int stellar_packet_mq_subscribe(struct stellar *st, int topic_id, on_packet_msg_cb_func *plugin_on_msg_cb, int plugin_id); //packet plugin only + +int packet_mq_publish_message(struct packet *pkt, int topic_id, void *msg); + |
