rename packet_io_loop to stellar_event_base_loop

This commit is contained in:
yangwei
2022-07-20 20:20:31 +08:00
parent da47b80442
commit 6f558132a1
23 changed files with 160 additions and 118 deletions

View File

@@ -9,17 +9,17 @@ void *custom_decode(const char *payload, uint32_t len, void **pme)
return nullptr;
}
int custom_plugin_entry(const struct session *s, int what, struct packet *p, const char *payload, uint32_t len, void **pme)
int custom_plugin_entry(const struct stellar_session *s, int what, struct stellar_packet *p, const char *payload, uint32_t len, void **pme)
{
void *info= custom_decode(payload, len, pme);
struct session *new_session=session_manager_custom_session_derive(s, _event);
struct stellar_session_event_extras *info= (struct stellar_session_event_extras *)custom_decode(payload, len, pme);
struct stellar_session *new_session=session_manager_session_derive(s, "CUSTOM_A");
session_manager_trigger_event(new_session, SESSION_EVENT_OPENING, info);
session_manager_trigger_event(new_session, SESSION_EVENT_META, info);
return 0;
}
int custom_event_plugin_entry(const struct session *s, int what, struct packet *p, const char *payload, uint32_t len, void **pme)
int custom_event_plugin_entry(const struct stellar_session *s, int what, struct stellar_packet *p, const char *payload, uint32_t len, void **pme)
{
return 0;
@@ -27,9 +27,12 @@ int custom_event_plugin_entry(const struct session *s, int what, struct packet *
int custom_plugin_init()
{
_event = session_manager_custom_session_event_register("SESSION_TYPE_CUSTOM", (int)(SESSION_EVENT_OPENING|SESSION_EVENT_RAW_PKT|SESSION_EVENT_META|SESSION_EVENT_CLOSING));
plugin_session_event_register(SESSION_TYPE_TCP, custom_plugin_entry, nullptr);
plugin_custom_session_event_register("SESSION_TYPE_CUSTOM", custom_event_plugin_entry, nullptr);
plugin_session_event_register("TCP", custom_plugin_entry, nullptr);
plugin_session_event_register("CUSTOM_A", custom_event_plugin_entry, nullptr);
return 0;
}
void custom_plugin_destroy()
{
return ;
}

View File

@@ -5,13 +5,18 @@
int http_event_plugin_entry(const struct session *s, int what, struct packet *p, const char *payload, uint32_t len, void **pme)
int http_event_plugin_entry(const struct stellar_session *s, int what, struct stellar_packet *p, const char *payload, uint32_t len, void **pme)
{
return 0;
}
int http_event_plugin_init()
{
plugin_session_event_register(SESSION_TYPE_HTTP, http_event_plugin_entry, nullptr);
plugin_session_event_register("HTTP", http_event_plugin_entry, nullptr);
return 0;
}
void http_event_plugin_destroy()
{
return ;
}

View File

View File

@@ -0,0 +1,13 @@
[PLUGINFO]
INIT_FUNC=custom_plugin_init
DESTROY_FUNC=custom_plugin_destroy
LIBARY_PATH=./plugins/custom_event_plugin/custom_event_plugin.so
[SESSION_TYPE.TCP]
SESSION_EVENT_TYPE=ALL
SESSION_EVENT_CALLBACK=custom_plugin_entry
[SESSION_TYPE.CUSTOM_A]
SESSION_EVENT_TYPE=ALL
SESSION_EVENT_CALLBACK=custom_event_plugin_entry

View File

@@ -0,0 +1,9 @@
[PLUGINFO]
INIT_FUNC=http_event_plugin_init
DESTROY_FUNC=http_event_plugin_destroy
LIBARY_PATH=./plugins/http_event_plugin/http_event_plugin.so
[SESSION_TYPE_HTTP]
SESSION_EVENT_TYPE=ALL
SESSION_EVENT_CALLBACK=http_event_plugin_entry

View File

@@ -0,0 +1,2 @@
./http_event_plugin/http_event_plugin.inf
./custom_event_plugin/custom_event_plugin.inf