mod_event_socket: sendevent Fire events with correct event-name and subclass (MODEVENT-41)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14354 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2009-07-24 20:13:36 +00:00
parent e7ec98273f
commit b0daf34ad5
3 changed files with 21 additions and 0 deletions

View File

@ -163,6 +163,9 @@ SWITCH_DECLARE(char *) switch_event_get_body(switch_event_t *event);
SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack,
const char *header_name, const char *fmt, ...) PRINTF_FUNCTION(4, 5);
#endif
SWITCH_DECLARE(switch_status_t) switch_event_set_subclass_name(switch_event_t *event, const char *subclass_name);
/*!
\brief Add a string header to an event
\param event the event to add the header to

View File

@ -1085,6 +1085,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
}
}
if (var && val) {
switch_event_del_header(*event, var);
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, var, val);
if (!strcasecmp(var, "content-length")) {
clen = atoi(val);
@ -1687,7 +1688,12 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
if (ename) {
switch_event_types_t etype;
if (switch_name_event(ename, &etype) == SWITCH_STATUS_SUCCESS) {
const char *subclass_name = switch_event_get_header(*event, "Event-Subclass");
(*event)->event_id = etype;
if (etype == SWITCH_EVENT_CUSTOM && subclass_name) {
switch_event_set_subclass_name(*event, subclass_name);
}
}
}

View File

@ -782,6 +782,17 @@ SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, s
return switch_event_base_add_header(event, stack, header_name, data);
}
SWITCH_DECLARE(switch_status_t) switch_event_set_subclass_name(switch_event_t *event, const char *subclass_name)
{
if (!event || !subclass_name) return SWITCH_STATUS_GENERR;
switch_safe_free(event->subclass_name);
event->subclass_name = DUP(subclass_name);
switch_event_del_header(event, "Event-Subclass");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Subclass", subclass_name);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
{
if (data) {
@ -848,6 +859,7 @@ SWITCH_DECLARE(void) switch_event_destroy(switch_event_t **event)
*event = NULL;
}
SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_event_t *todup)
{
switch_event_header_t *hp;