rename fn_session_event_callback to plugin_event_callback and update API parameters
* plugin_event_callback delete 'struct stellar_packet *p'
* plugin_event_callback rename 'uint16_t len' to 'size_t len'
* plugin_event_callback rename 'void **pme' to 'void **ctx'
This commit is contained in:
@@ -8,40 +8,40 @@
|
||||
|
||||
static char *g_handler = NULL;
|
||||
|
||||
struct http_session_pme
|
||||
struct http_session_ctx
|
||||
{
|
||||
char data[16];
|
||||
/* data */;
|
||||
};
|
||||
|
||||
static struct http_session_pme *http_session_pme_create()
|
||||
static struct http_session_ctx *http_session_ctx_create()
|
||||
{
|
||||
struct http_session_pme *pme = (struct http_session_pme *)calloc(1, sizeof(struct http_session_pme));
|
||||
return pme;
|
||||
struct http_session_ctx *ctx = (struct http_session_ctx *)calloc(1, sizeof(struct http_session_ctx));
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void http_session_pme_destory(struct http_session_pme *pme)
|
||||
static void http_session_ctx_destory(struct http_session_ctx *ctx)
|
||||
{
|
||||
if (pme)
|
||||
if (ctx)
|
||||
{
|
||||
free(pme);
|
||||
pme = NULL;
|
||||
free(ctx);
|
||||
ctx = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void http_event_plugin_entry(const struct stellar_session *session, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme)
|
||||
extern "C" void http_event_plugin_entry(const struct stellar_session *session, enum session_event_type event, const char *payload, size_t len, void **ctx)
|
||||
{
|
||||
struct http_session_pme **per_http_session_pme = (struct http_session_pme **)pme;
|
||||
struct http_session_ctx **per_http_session_ctx = (struct http_session_ctx **)ctx;
|
||||
|
||||
printf("RUN http_event_plugin_entry, event: %d\n", event);
|
||||
|
||||
if (event & SESSION_EVENT_OPENING)
|
||||
{
|
||||
if (*per_http_session_pme == NULL)
|
||||
if (*per_http_session_ctx == NULL)
|
||||
{
|
||||
struct http_session_pme *cur_ctx = http_session_pme_create();
|
||||
struct http_session_ctx *cur_ctx = http_session_ctx_create();
|
||||
memcpy(cur_ctx->data, "http_event_plugin_entry", strlen("http_event_plugin_entry"));
|
||||
*per_http_session_pme = *&cur_ctx;
|
||||
*per_http_session_ctx = *&cur_ctx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ extern "C" void http_event_plugin_entry(const struct stellar_session *session, e
|
||||
|
||||
if (event & SESSION_EVENT_CLOSING)
|
||||
{
|
||||
http_session_pme_destory(*per_http_session_pme);
|
||||
http_session_ctx_destory(*per_http_session_ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user