rename packet_io_loop to stellar_event_base_loop
This commit is contained in:
@@ -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 ;
|
||||
}
|
||||
@@ -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 ;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
2
sdk/example/plugins/plugins.inf
Normal file
2
sdk/example/plugins/plugins.inf
Normal file
@@ -0,0 +1,2 @@
|
||||
./http_event_plugin/http_event_plugin.inf
|
||||
./custom_event_plugin/custom_event_plugin.inf
|
||||
18
sdk/include/event.h
Normal file
18
sdk/include/event.h
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
enum stellar_event_type
|
||||
{
|
||||
STELLAR_SESSION_EVENT,
|
||||
};
|
||||
|
||||
struct stellar_session_event_data;
|
||||
|
||||
struct stellar_event
|
||||
{
|
||||
stellar_event_type type;
|
||||
union
|
||||
{
|
||||
struct stellar_session_event_data *session_event_data;
|
||||
void *event_data;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
#include "packet.h"
|
||||
#include "session.h"
|
||||
|
||||
int http_decoder(const struct session *s, int what, struct packet *p, const char *payload, uint32_t len, void **pme);
|
||||
int http_decoder(const struct stellar_session *s, int what, struct stellar_packet *p, const char *payload, uint32_t len, void **pme);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
struct packet;
|
||||
struct stellar_packet;
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include "session.h"
|
||||
#include <time.h>
|
||||
|
||||
int plugin_session_event_register(int session_type, fn_session_event_callback cb, void *entry_arg);
|
||||
int plugin_session_timer_register(struct session *s, fn_session_timer cb, void *timer_arg, const struct timeval *timeout);
|
||||
int plugin_session_event_register(const char *session_name,
|
||||
fn_session_event_callback call_back,
|
||||
const struct timeval *timeout);
|
||||
|
||||
int plugin_custom_session_event_register(const char *event_name, fn_session_event_callback cb, void *entry_arg);
|
||||
void plugin_session_event_delete(struct stellar_event *ev,
|
||||
struct stellar_session *s);
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "packet.h"
|
||||
#include "event.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct session;
|
||||
struct session_event;
|
||||
struct stellar_session;
|
||||
|
||||
enum session_type
|
||||
enum stellar_session_type
|
||||
{
|
||||
SESSION_TYPE_CUSTOM,
|
||||
SESSION_TYPE_IP,
|
||||
@@ -23,7 +23,7 @@ enum session_type
|
||||
SESSION_TYPE_MAX,
|
||||
};
|
||||
|
||||
enum session_event_type
|
||||
enum stellar_session_event_type
|
||||
{
|
||||
SESSION_EVENT_OPENING=0x01,
|
||||
SESSION_EVENT_RAW_PKT=0x02,
|
||||
@@ -32,19 +32,13 @@ enum session_event_type
|
||||
SESSION_EVENT_CLOSING=0x10,
|
||||
};
|
||||
|
||||
struct stellar_session_event_extras;
|
||||
|
||||
typedef int (*fn_session_event_callback)(const struct session *s, int what, struct packet *p, const char *payload, uint32_t len, void **pme);
|
||||
typedef int (*fn_session_timer)(const struct session *s, void **pme);
|
||||
typedef int (*fn_session_event_callback)(const struct stellar_session *s, int what, struct stellar_packet *p, const char *payload, uint32_t len, void **pme);
|
||||
|
||||
void session_manager_trigger_event(struct session *s, session_event_type event, void *event_info);
|
||||
void session_manager_trigger_event(struct stellar_session *s,
|
||||
stellar_session_event_type type,
|
||||
struct stellar_session_event_extras *info);
|
||||
|
||||
|
||||
struct session_event *session_manager_commit(struct packet *p);
|
||||
|
||||
struct custom_session_event;
|
||||
|
||||
struct custom_session_event *session_manager_custom_session_event_register(const char *event_name, int available_event);
|
||||
struct session *session_manager_custom_session_derive(const struct session *cur_session, struct custom_session_event *event);
|
||||
|
||||
|
||||
struct session_event *session_manager_fetch_event();
|
||||
struct stellar_session *session_manager_session_derive(const struct stellar_session *this_session,
|
||||
const char *new_session_name);
|
||||
Reference in New Issue
Block a user