diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 2387f1f662..f15c8acd20 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -136,6 +136,16 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg); }; + class EventConsumer { + protected: + switch_event_types_t e_event_id; + switch_event_node_t *node; + char *e_callback; + char *e_subclass_name; + public: + SWITCH_DECLARE_CONSTRUCTOR EventConsumer(switch_event_types_t event_id, const char *subclass_name = "", const char *callback = "event_consumer"); + SWITCH_DECLARE_CONSTRUCTOR ~ EventConsumer(); + }; class CoreSession { protected: diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index e8ea6af99b..c3a5a1a93e 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1532,7 +1532,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu gateway->status = SOFIA_GATEWAY_DOWN; if (gateway->state == REG_STATE_REGED) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "unregister %s\n", gateway->name); - gateway->state = REG_STATE_UNREGISTER; + gateway->state = REG_STATE_FAILED; } } gateway->ping = switch_timestamp(NULL) + gateway->ping_freq; diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 3697541be3..c28d3c0bf0 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -112,7 +112,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) break; case REG_STATE_UNREGED: gateway_ptr->status = SOFIA_GATEWAY_DOWN; - sofia_reg_kill_reg(gateway_ptr, 1); + sofia_reg_kill_reg(gateway_ptr, 0); if ((gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, NUTAG_URL(gateway_ptr->register_proxy), diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 47f74030cb..6c595144e8 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -37,6 +37,40 @@ #pragma warning(disable:4127 4003) #endif +static void event_handler(switch_event_t *event) +{ +} + +SWITCH_DECLARE_CONSTRUCTOR EventConsumer::EventConsumer(switch_event_types_t event_id, const char *subclass_name, const char *callback) +{ + e_event_id = event_id; + + if (!switch_strlen_zero(subclass_name)) { + e_subclass_name = strdup(subclass_name); + } else { + e_subclass_name = ""; + } + + if (switch_strlen_zero(callback)) { + callback = "event_consumer"; + } + + e_callback = strdup(callback); + + + switch_event_bind_removable(__FILE__, e_event_id, subclass_name, event_handler, this, &node); +} + + +SWITCH_DECLARE_CONSTRUCTOR EventConsumer::~EventConsumer() +{ + switch_safe_free(e_subclass_name); + switch_safe_free(e_callback); + + if (node) { + switch_event_unbind(&node); + } +} SWITCH_DECLARE_CONSTRUCTOR IVRMenu::IVRMenu(IVRMenu *main, const char *name, diff --git a/src/switch_event.c b/src/switch_event.c index 1656105820..cae16e6e53 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -541,15 +541,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **ev (*event)->event_id = event_id; if (subclass_name) { - switch_event_subclass_t *subclass; - - if (!(subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) { - switch_event_reserve_subclass((char *) subclass_name); - subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name); - } - (*event)->subclass_name = DUP(subclass_name); - switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", subclass_name); }