diff options
| author | luwenpeng <[email protected]> | 2024-10-25 19:15:28 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2024-10-25 19:15:45 +0800 |
| commit | 03864c9731ec87ed6c7e1fbe3c5f261880e857dc (patch) | |
| tree | 2b2343f491faf890889411b1a69a3f40b956e58f /include | |
| parent | 4061d5a942392c4716586ded8c586440d2e920ca (diff) | |
Add state to the on_session_message parameter.
* When state is closed, it implies that packet is null and the session will be destroyed
Diffstat (limited to 'include')
| -rw-r--r-- | include/stellar/session.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/include/stellar/session.h b/include/stellar/session.h index aff1974..4710dfa 100644 --- a/include/stellar/session.h +++ b/include/stellar/session.h @@ -151,15 +151,15 @@ struct session_manager; struct session_manager *stellar_module_get_session_manager(struct stellar_module_manager *mod_mgr); int session_manager_new_session_exdata_index(struct session_manager *sess_mgr, const char *name, exdata_free *func, void *arg); -typedef void on_session_free_callback(struct session *sess, void *args); -typedef void on_session_packet_callback(struct session *sess, struct packet *pkt, void *args); -typedef void on_tcp_stream_callback(struct session *sess, const char *tcp_payload, uint32_t tcp_payload_len, void *args); - -int session_manager_subscribe_free(struct session_manager *sess_mgr, on_session_free_callback *cb, void *args); -int session_manager_subscribe_tcp(struct session_manager *sess_mgr, on_session_packet_callback *cb, void *args); -int session_manager_subscribe_udp(struct session_manager *sess_mgr, on_session_packet_callback *cb, void *args); -int session_manager_subscribe_control_packet(struct session_manager *sess_mgr, on_session_packet_callback *cb, void *args); -int session_manager_subscribe_tcp_stream(struct session_manager *sess_mgr, on_tcp_stream_callback *cb, void *args); +// When the state is SESSION_STATE_CLOSED, the packet is NULL, and the session will be destroyed. +typedef void on_session_message_callback(struct session *sess, enum session_state state, struct packet *pkt, void *args); +// When the state is SESSION_STATE_CLOSED, the tcp_payload is NULL, and the session will be destroyed. +typedef void on_tcp_payload_callback(struct session *sess, enum session_state state, const char *tcp_payload, uint32_t tcp_payload_len, void *args); + +int session_manager_subscribe_tcp(struct session_manager *sess_mgr, on_session_message_callback *cb, void *args); +int session_manager_subscribe_udp(struct session_manager *sess_mgr, on_session_message_callback *cb, void *args); +int session_manager_subscribe_control_packet(struct session_manager *sess_mgr, on_session_message_callback *cb, void *args); +int session_manager_subscribe_tcp_stream(struct session_manager *sess_mgr, on_tcp_payload_callback *cb, void *args); #ifdef __cplusplus } |
