|
Defines |
| #define | MAX_DISPATCH 20 |
| #define | DISPATCH_QUEUE_LEN 5000 |
| #define | NUMBER_OF_QUEUES 3 |
| #define | ALLOC(size) malloc(size) |
| #define | DUP(str) my_dup(str) |
| #define | FREE(ptr) switch_safe_free(ptr) |
| #define | resize(l) |
Functions |
| void | switch_event_deliver (switch_event_t **event) |
| | Deliver an event to all of the registered event listeners.
|
| switch_status_t | switch_event_running (void) |
| | Determine if the event system has been initilized.
|
| const char * | switch_event_name (switch_event_types_t event) |
| | Render the name of an event id enumeration.
|
| switch_status_t | switch_name_event (const char *name, switch_event_types_t *type) |
| | return the event id that matches a given event name
|
| switch_status_t | switch_event_reserve_subclass_detailed (const char *owner, const char *subclass_name) |
| | Reserve a subclass name for private use with a custom event.
|
| void | switch_core_memory_reclaim_events (void) |
| switch_status_t | switch_event_shutdown (void) |
| | Stop the eventing system.
|
| switch_status_t | switch_event_init (switch_memory_pool_t *pool) |
| | Start the eventing system.
|
| switch_status_t | switch_event_create_subclass (switch_event_t **event, switch_event_types_t event_id, const char *subclass_name) |
| | Create an event.
|
| switch_status_t | switch_event_set_priority (switch_event_t *event, switch_priority_t priority) |
| | Set the priority of an event.
|
| char * | switch_event_get_header (switch_event_t *event, char *header_name) |
| | Retrieve a header value from an event.
|
| char * | switch_event_get_body (switch_event_t *event) |
| | Retrieve the body value from an event.
|
| switch_status_t | switch_event_del_header (switch_event_t *event, const char *header_name) |
| switch_status_t | switch_event_add_header (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) |
| switch_status_t | switch_event_add_header_string (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data) |
| | Add a string header to an event.
|
| switch_status_t | switch_event_add_body (switch_event_t *event, const char *fmt,...) |
| void | switch_event_destroy (switch_event_t **event) |
| | Destroy an event.
|
| switch_status_t | switch_event_dup (switch_event_t **event, switch_event_t *todup) |
| | Duplicate an event.
|
| switch_status_t | switch_event_serialize (switch_event_t *event, char **str, switch_bool_t encode) |
| | Render a string representation of an event sutable for printing or network transport.
|
| switch_xml_t | switch_event_xmlize (switch_event_t *event, const char *fmt,...) |
| switch_status_t | switch_event_fire_detailed (const char *file, const char *func, int line, switch_event_t **event, void *user_data) |
| | Fire an event with full arguement list.
|
| switch_status_t | switch_event_bind (const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data) |
| | Bind an event callback to a specific event.
|
| switch_status_t | switch_event_create_pres_in_detailed (char *file, char *func, int line, const char *proto, const char *login, const char *from, const char *from_domain, const char *status, const char *event_type, const char *alt_event_type, int event_count, const char *unique_id, const char *channel_state, const char *answer_state, const char *call_direction) |
| char * | switch_event_expand_headers (switch_event_t *event, const char *in) |
| char * | switch_event_build_param_string (switch_event_t *event, const char *prefix, switch_hash_t *vars_map) |
|
|
01008 {
01009 switch_event_t *pres_event;
01010
01011 if (switch_event_create_subclass(&pres_event, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY) == SWITCH_STATUS_SUCCESS) {
01012 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "proto", proto);
01013 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "login", login);
01014 switch_event_add_header(pres_event, SWITCH_STACK_TOP, "from", "%s@%s", from, from_domain);
01015 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "status", status);
01016 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "event_type", event_type);
01017 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "alt_event_type", alt_event_type);
01018 switch_event_add_header(pres_event, SWITCH_STACK_TOP, "event_count", "%d", event_count);
01019 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "unique-id", alt_event_type);
01020 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "channel-state", channel_state);
01021 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "answer-state", answer_state);
01022 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "call-direction", call_direction);
01023 switch_event_fire_detailed(file, func, line, &pres_event, NULL);
01024 return SWITCH_STATUS_SUCCESS;
01025 }
01026 return SWITCH_STATUS_MEMERR;
01027 }
|
|
|
00848 {
00849 switch_event_header_t *hp;
00850 char *data = NULL, *body = NULL;
00851 int ret = 0;
00852 switch_xml_t xml = NULL;
00853 uint32_t off = 0;
00854 va_list ap;
00855
00856 if (!(xml = switch_xml_new("event"))) {
00857 return xml;
00858 }
00859
00860 if (fmt) {
00861 va_start(ap, fmt);
00862 #ifdef HAVE_VASPRINTF
00863 ret = vasprintf(&data, fmt, ap);
00864 #else
00865 data = (char *) malloc(2048);
00866 if (!data) return NULL;
00867 ret = vsnprintf(data, 2048, fmt, ap);
00868 #endif
00869 va_end(ap);
00870 if (ret == -1) {
00871 #ifndef HAVE_VASPRINTF
00872 free(data);
00873 #endif
00874 return NULL;
00875 }
00876 }
00877
00878 for (hp = event->headers; hp; hp = hp->next) {
00879 add_xml_header(xml, hp->name, hp->value, off++);
00880 }
00881
00882 if (!switch_strlen_zero(data)) {
00883 body = data;
00884 } else if (event->body) {
00885 body = event->body;
00886 }
00887
00888 if (body) {
00889 int blen = (int) strlen(body);
00890 char blena[25];
00891 switch_snprintf(blena, sizeof(blena), "%d", blen);
00892 if (blen) {
00893 switch_xml_t xbody = NULL;
00894
00895 add_xml_header(xml, "Content-Length", blena, off++);
00896 if ((xbody = switch_xml_add_child_d(xml, "body", off++))) {
00897 switch_xml_set_txt_d(xbody, body);
00898 }
00899 }
00900 }
00901
00902 if (data) {
00903 free(data);
00904 }
00905
00906 return xml;
00907 }
|