Refactored pm_session_dettach_others to pm_session_take_over

This commit is contained in:
luwenpeng
2022-08-08 14:19:32 +08:00
parent fd2a67e0eb
commit 0f7468b994
20 changed files with 91 additions and 143 deletions

View File

@@ -2,5 +2,4 @@
#include "session.h"
void http_decoder(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme);
void http_error_cb(const struct stellar_session *s, enum error_event_type event, void **pme);
void http_decoder(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme);

View File

@@ -15,8 +15,21 @@ typedef void plugin_exit_callback(void);
* Public API For Plugin
******************************************************************************/
/*
* The pm_session_dettach_me just sets the flag to disable this plugin and no longer call this event callback.
* Before calling pm_session_dettach_me, the current plugin must release related resources for the current session.
*/
void pm_session_dettach_me(const struct stellar_session *session);
void pm_session_dettach_others(const struct stellar_session *session);
/*
* The current plugin takes over the current session, the pm_session_take_over setting flag disables other plugins,
* and the current session does not call other plugins except for the SESSION_EVENT_CLOSING event.
*
* The current plugin may be taken over while the session is open (SESSION_EVENT_OPENING),
* other plugins event_cb is not called, the session pme on other plugins is NULL,
* When the session is closed (SESSION_EVENT_CLOSING), call other plugin even_cb to destroy pme must check if pme is NULL.
*/
void pm_session_take_over(const struct stellar_session *session);
#ifdef __cpluscplus
}

View File

@@ -40,14 +40,8 @@ enum session_event_type
SESSION_EVENT_ALL = (0x01 << 1 | 0x01 << 2 | 0x01 << 3 | 0x01 << 4 | 0x01 << 5),
};
enum error_event_type
{
ERROR_EVENT_DETTACH = (0x1 << 10),
};
struct stellar_session_event_extras;
typedef void(fn_session_error_callback)(const struct stellar_session *s, enum error_event_type event, void **pme);
typedef void(fn_session_event_callback)(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme);
void session_manager_trigger_event(struct stellar_session *s, enum session_event_type type, struct stellar_session_event_extras *info);