<pre>
SWITCH_EVENT_CUSTOM - A custom event
- SWITCH_EVENT_CHANNEL_CREATE - A channel has changed state
+ SWITCH_EVENT_CHANNEL_CREATE - A channel has been created
+ SWITCH_EVENT_CHANNEL_DESTROY - A channel has been destroyed
SWITCH_EVENT_CHANNEL_STATE - A channel has changed state
SWITCH_EVENT_CHANNEL_ANSWER - A channel has been answered
SWITCH_EVENT_CHANNEL_HANGUP - A channel has been hungup
typedef enum {
SWITCH_EVENT_CUSTOM,
SWITCH_EVENT_CHANNEL_CREATE,
+ SWITCH_EVENT_CHANNEL_DESTROY,
SWITCH_EVENT_CHANNEL_STATE,
SWITCH_EVENT_CHANNEL_ANSWER,
SWITCH_EVENT_CHANNEL_HANGUP,
if (ok) {
+ switch_event *event;
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", channel->name,
state_names[last_state], state_names[state]);
channel->state = state;
channel->hangup_cause = SWITCH_CAUSE_NORMAL_CLEARING;
}
+ if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(channel, event);
+ switch_event_fire(&event);
+ }
+
if (state < CS_DONE) {
switch_core_session_signal_state_change(channel->session);
}
}
if (channel->state < CS_HANGUP) {
+ switch_event *event;
+
channel->state = CS_HANGUP;
channel->hangup_cause = hangup_cause;
+ if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(channel, event);
+ switch_event_fire(&event);
+ }
+
switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL);
switch_core_session_signal_state_change(channel->session);
}
switch_mutex_lock(session->mutex);
while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
- switch_event *event;
-
if (state != laststate) {
int index = 0;
int proceed = 1;
midstate = state;
- if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
- switch_channel_event_set_data(session->channel, event);
- switch_event_fire(&event);
- }
switch (state) {
case CS_NEW: /* Just created, Waiting for first instructions */
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session)
{
switch_memory_pool *pool;
+ switch_event *event;
+
+ if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DESTROY) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(session->channel, event);
+ switch_event_fire(&event);
+ }
pool = (*session)->pool;
*session = NULL;
}
switch (event->event_id) {
+
+ case SWITCH_EVENT_CHANNEL_DESTROY:
+ snprintf(buf, sizeof(buf), "delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
+ sql = buf;
+ break;
case SWITCH_EVENT_CHANNEL_CREATE:
snprintf(buf, sizeof(buf), "insert into channels (uuid,created,name,state) values('%s','%s','%s','%s')",
switch_event_get_header(event, "unique-id"),
switch(state_i) {
case CS_HANGUP:
- snprintf(buf, sizeof(buf), "delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
- sql = buf;
+ case CS_DONE:
break;
case CS_RING:
snprintf(buf, sizeof(buf), "update channels set state='%s',cid_name='%s',cid_num='%s',ip_addr='%s',dest='%s'"
break;
}
}
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL [%s]\n", sql);
}
}