plugin_manager adapt session_manager API and rewrite plugin_manger gtest
This commit is contained in:
@@ -14,7 +14,7 @@ extern "C"
|
||||
* Public API: For build in
|
||||
******************************************************************************/
|
||||
|
||||
void http_entry(const struct stellar_session *session, enum session_event_type event, const char *payload, size_t len, void **ctx);
|
||||
void http_entry(struct stellar_session *session, enum session_state state, int thread_id, void **ctx);
|
||||
|
||||
/******************************************************************************
|
||||
* Public API: For http consumer
|
||||
@@ -56,7 +56,7 @@ struct http_status_line
|
||||
int minor_version;
|
||||
};
|
||||
|
||||
struct http_decoder *http_session_get_decoder(const struct stellar_session *http_session);
|
||||
struct http_decoder *http_session_get_decoder(struct stellar_session *http_session);
|
||||
enum http_event http_decoder_get_event(struct http_decoder *decoder);
|
||||
|
||||
/*
|
||||
@@ -73,7 +73,7 @@ void http_decoder_fetch_next_header(struct http_decoder *decoder, int *iter_inde
|
||||
* Example: How to implement http consumer
|
||||
******************************************************************************/
|
||||
/*
|
||||
void http_consumer_entry_example(const struct stellar_session *http_session, enum session_event_type event, const char *payload, size_t len, void **ctx)
|
||||
void http_consumer_entry_example(struct stellar_session *http_session, enum session_event_type event, const char *payload, size_t len, void **ctx)
|
||||
{
|
||||
if (event & SESSION_EVENT_OPENING)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ extern "C"
|
||||
|
||||
typedef int plugin_init_callback(void);
|
||||
typedef void plugin_exit_callback(void);
|
||||
typedef void plugin_event_callback(const struct stellar_session *session, enum session_state state, int thread_id, void **ctx);
|
||||
typedef void plugin_entry_callback(struct stellar_session *session, enum session_state state, int thread_id, void **ctx);
|
||||
|
||||
/******************************************************************************
|
||||
* Public API For Plugin
|
||||
@@ -22,7 +22,7 @@ typedef void plugin_event_callback(const struct stellar_session *session, enum s
|
||||
* 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_me(struct stellar_session *session);
|
||||
|
||||
/*
|
||||
* The current plugin(cb2) takes over the current session, the pm_session_take_over setting flag disables other plugins,
|
||||
@@ -38,7 +38,7 @@ void pm_session_dettach_me(const struct stellar_session *session);
|
||||
* A plugin(cb1/cb3/cb4) that is taken over, if the plugin was called before being taken over and has a registered SESSION_EVENT_CLOSING event,
|
||||
* it will be called again when the SESSION_EVENT_CLOSING event comes. Otherwise, the plugin will not be called.
|
||||
*/
|
||||
void pm_session_take_over(const struct stellar_session *session);
|
||||
void pm_session_take_over(struct stellar_session *session);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
|
||||
@@ -38,43 +38,27 @@ enum session_type
|
||||
SESSION_TYPE_MAX,
|
||||
};
|
||||
|
||||
//http decoder
|
||||
enum http_stage
|
||||
{
|
||||
HTTP_STAGE_REQ_HDR=1<<1,
|
||||
HTTP_STAGE_REQ_BODY_BEGIN=1<<2,
|
||||
HTTP_STAGE_REQ_BODY_CONTINUE=1<<3,
|
||||
HTTP_STAGE_REQ_BODY_END,
|
||||
HTTP_STAGE_RESP_HDR,
|
||||
HTTP_STAGE_RESP_BODY
|
||||
};
|
||||
|
||||
//dns decoder
|
||||
enum dns_stage
|
||||
{
|
||||
DNS_STAGE_REQUEST,
|
||||
DNS_STAGE_RESPONSE
|
||||
};
|
||||
|
||||
enum session_state
|
||||
{
|
||||
SESSION_STATE_OPENING,
|
||||
SESSION_STATE_ACTIVE,
|
||||
SESSION_STATE_CLOSING
|
||||
SESSION_STATE_INVALID = 0,
|
||||
SESSION_STATE_OPENING = 1 << 1,
|
||||
SESSION_STATE_ACTIVE = 1 << 2,
|
||||
SESSION_STATE_CLOSING = 1 << 3,
|
||||
SESSION_STATE_ALL = (1 << 1 | 1 << 2 | 1 << 3),
|
||||
};
|
||||
|
||||
struct stellar_session;
|
||||
struct stellar_session *session_derive(const struct stellar_session *this_session, const char *session_name);
|
||||
void session_close(const struct stellar_session *session);
|
||||
struct stellar_session *session_derive(struct stellar_session *this_session, const char *session_name);
|
||||
void session_close(struct stellar_session *session);
|
||||
|
||||
const char *session_get_name(const struct stellar_session *session);
|
||||
const char *session_get_name(struct stellar_session *session);
|
||||
|
||||
uint8_t session_get_direction(const struct stellar_session *session); // tcp or udp
|
||||
uint8_t session_get_current_direction(const struct stellar_session *session); // tcp or udp
|
||||
uint8_t session_get_direction(struct stellar_session *session); // tcp or udp
|
||||
uint8_t session_get_current_direction(struct stellar_session *session); // tcp or udp
|
||||
|
||||
uint64_t session_get_createtime_ms(const struct stellar_session *session);
|
||||
uint64_t session_get_lasttime_ms(const struct stellar_session *session);
|
||||
enum session_type session_get_type(const struct stellar_session *session);
|
||||
uint64_t session_get_createtime_ms(struct stellar_session *session);
|
||||
uint64_t session_get_lasttime_ms(struct stellar_session *session);
|
||||
enum session_type session_get_type(struct stellar_session *session);
|
||||
struct stellar_packet *session_get_packet(struct stellar_session *session);
|
||||
enum session_state session_get_state(struct stellar_session *session);
|
||||
const char *session_get_payload(struct stellar_session *session);
|
||||
|
||||
Reference in New Issue
Block a user