Skinny: handle UnregisterMessage and properly flush listener
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16820 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c84d664c6b
commit
adde57cb24
|
@ -990,7 +990,28 @@ static void walk_listeners(skinny_listener_callback_func_t callback, void *pvt)
|
|||
static void flush_listener(listener_t *listener, switch_bool_t flush_log, switch_bool_t flush_events)
|
||||
{
|
||||
|
||||
/* TODO */
|
||||
if(!zstr(listener->device_name)) {
|
||||
skinny_profile_t *profile = listener->profile;
|
||||
char *sql;
|
||||
|
||||
if ((sql = switch_mprintf(
|
||||
"DELETE FROM skinny_devices "
|
||||
"WHERE name='%s'",
|
||||
listener->device_name))) {
|
||||
skinny_execute_sql(profile, sql, profile->listener_mutex);
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
|
||||
if ((sql = switch_mprintf(
|
||||
"DELETE FROM skinny_buttons "
|
||||
"WHERE device_name='%s'",
|
||||
listener->device_name))) {
|
||||
skinny_execute_sql(profile, sql, profile->listener_mutex);
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
|
||||
strcpy(listener->device_name, "");
|
||||
}
|
||||
}
|
||||
|
||||
static int dump_device_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
|
|
|
@ -109,6 +109,7 @@ struct skinny_table SKINNY_MESSAGE_TYPES[] = {
|
|||
{"DisplayPromptStatusMessage", DISPLAY_PROMPT_STATUS_MESSAGE},
|
||||
{"ClearPromptStatusMessage", CLEAR_PROMPT_STATUS_MESSAGE},
|
||||
{"ActivateCallPlaneMessage", ACTIVATE_CALL_PLANE_MESSAGE},
|
||||
{"UnregisterAckMessage", UNREGISTER_ACK_MESSAGE},
|
||||
{"DialedNumberMessage", DIALED_NUMBER_MESSAGE},
|
||||
{"FeatureResMessage", FEATURE_STAT_RES_MESSAGE},
|
||||
{NULL, 0}
|
||||
|
@ -1997,9 +1998,21 @@ switch_status_t skinny_handle_on_hook_message(listener_t *listener, skinny_messa
|
|||
switch_status_t skinny_handle_unregister(listener_t *listener, skinny_message_t *request)
|
||||
{
|
||||
switch_event_t *event = NULL;
|
||||
skinny_message_t *message;
|
||||
|
||||
/* skinny::unregister event */
|
||||
skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_UNREGISTER);
|
||||
switch_event_fire(&event);
|
||||
|
||||
message = switch_core_alloc(listener->pool, 12+sizeof(message->data.unregister_ack));
|
||||
message->type = UNREGISTER_ACK_MESSAGE;
|
||||
message->length = 4 + sizeof(message->data.unregister_ack);
|
||||
message->data.unregister_ack.unregister_status = 0; /* OK */
|
||||
skinny_send_reply(listener, message);
|
||||
|
||||
/* Close socket */
|
||||
switch_clear_flag_locked(listener, LFLAG_RUNNING);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2061,8 +2074,8 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re
|
|||
case UNREGISTER_MESSAGE:
|
||||
return skinny_handle_unregister(listener, request);
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Unknown request type: %x (length=%d).\n", request->type, request->length);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"Unhandled request %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -441,6 +441,12 @@ struct activate_call_plane_message {
|
|||
uint32_t line_instance;
|
||||
};
|
||||
|
||||
/* UnregisterAckMessage */
|
||||
#define UNREGISTER_ACK_MESSAGE 0x0118
|
||||
struct unregister_ack_message {
|
||||
uint32_t unregister_status;
|
||||
};
|
||||
|
||||
/* DialedNumberMessage */
|
||||
#define DIALED_NUMBER_MESSAGE 0x011D
|
||||
struct dialed_number_message {
|
||||
|
@ -506,6 +512,7 @@ union skinny_data {
|
|||
struct display_prompt_status_message display_prompt_status;
|
||||
struct clear_prompt_status_message clear_prompt_status;
|
||||
struct activate_call_plane_message activate_call_plane;
|
||||
struct unregister_ack_message unregister_ack;
|
||||
struct dialed_number_message dialed_number;
|
||||
struct feature_stat_res_message feature_res;
|
||||
|
||||
|
@ -619,7 +626,7 @@ uint32_t func(const char *str)\
|
|||
status = SWITCH_STATUS_SUCCESS;\
|
||||
}
|
||||
|
||||
struct skinny_table SKINNY_MESSAGE_TYPES[52];
|
||||
struct skinny_table SKINNY_MESSAGE_TYPES[53];
|
||||
const char *skinny_message_type2str(uint32_t id);
|
||||
uint32_t skinny_str2message_type(const char *str);
|
||||
#define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES)
|
||||
|
|
Loading…
Reference in New Issue