Merge branch develop-0.0
This commit is contained in:
12
sdk/include/event.h
Normal file
12
sdk/include/event.h
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
struct stellar_session_event_data;
|
||||
|
||||
struct stellar_event
|
||||
{
|
||||
union
|
||||
{
|
||||
struct stellar_session_event_data *session_event_data;
|
||||
void *event_data;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#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);
|
||||
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);
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct packet;
|
||||
struct stellar_packet;
|
||||
@@ -1,9 +1,44 @@
|
||||
#pragma once
|
||||
#ifndef _PLUGIN_H
|
||||
#define _PLUGIN_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#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);
|
||||
typedef int plugin_init_callback(void);
|
||||
typedef void plugin_exit_callback(void);
|
||||
|
||||
int plugin_custom_session_event_register(const char *event_name, fn_session_event_callback cb, void *entry_arg);
|
||||
/******************************************************************************
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* The current plugin(cb2) 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.
|
||||
*
|
||||
* +-----+ +-----+ +-----+ +-----+
|
||||
* Plugin runtime callback list: | cb1 |-->| cb2 |-->| cb3 |-->| cb4 |
|
||||
* +-----+ +-----+ +-----+ +-----+
|
||||
* /|\
|
||||
* |
|
||||
* plugin cb2 run pm_session_take_over
|
||||
*
|
||||
* 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);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,12 +1,18 @@
|
||||
#pragma once
|
||||
#ifndef _SESSION_H
|
||||
#define _SESSION_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#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,
|
||||
@@ -25,26 +31,26 @@ enum session_type
|
||||
|
||||
enum session_event_type
|
||||
{
|
||||
SESSION_EVENT_OPENING=0x01,
|
||||
SESSION_EVENT_RAW_PKT=0x02,
|
||||
SESSION_EVENT_ORDERED_PKT=0x04,
|
||||
SESSION_EVENT_META=0x08,
|
||||
SESSION_EVENT_CLOSING=0x10,
|
||||
SESSION_EVENT_UNKNOWN = (0x00),
|
||||
SESSION_EVENT_OPENING = (0x01 << 1),
|
||||
SESSION_EVENT_RAWPKT = (0x01 << 2),
|
||||
SESSION_EVENT_ORDPKT = (0x01 << 3),
|
||||
SESSION_EVENT_META = (0x01 << 4),
|
||||
SESSION_EVENT_CLOSING = (0x01 << 5),
|
||||
SESSION_EVENT_ALL = (0x01 << 1 | 0x01 << 2 | 0x01 << 3 | 0x01 << 4 | 0x01 << 5),
|
||||
};
|
||||
|
||||
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 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 session *s, session_event_type event, void *event_info);
|
||||
void session_manager_trigger_event(struct stellar_session *s, enum session_event_type type, struct stellar_session_event_extras *info);
|
||||
struct stellar_session *session_manager_session_derive(const struct stellar_session *this_session, const char *session_name);
|
||||
|
||||
const char *stellar_session_get_name(const struct stellar_session *session);
|
||||
|
||||
struct session_event *session_manager_commit(struct packet *p);
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
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();
|
||||
#endif
|
||||
@@ -14,6 +14,7 @@
|
||||
typedef enum {
|
||||
ST_OK = 0,
|
||||
ST_ERR_MEM_ALLOC,
|
||||
ST_ERR_STR_COPY,
|
||||
ST_ERR_RUN_MODE,
|
||||
ST_ERR_PIO_INSTANCE,
|
||||
ST_ERR_PIO_MARSIO_INSTANCE,
|
||||
|
||||
Reference in New Issue
Block a user