[Freeswitch-svn] [commit] r9883 - in freeswitch/trunk/src: . mod/applications/mod_commands
Freeswitch SVN
anthm at freeswitch.org
Tue Oct 7 17:42:32 EDT 2008
Author: anthm
Date: Tue Oct 7 17:42:31 2008
New Revision: 9883
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_core_session.c
Log:
more heartbeat work
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Tue Oct 7 17:42:31 2008
@@ -2321,6 +2321,57 @@
return SWITCH_STATUS_SUCCESS;
}
+#define HEARTBEAT_SYNTAX "<uuid> <on|off|<seconds>>"
+SWITCH_STANDARD_API(uuid_session_heartbeat_function)
+{
+ char *mycmd = NULL, *argv[2] = { 0 };
+ uint32_t seconds = 60;
+ int argc, tmp;
+ switch_core_session_t *l_session = NULL;
+
+ if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) {
+ goto error;
+ }
+
+ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+ if (argc != 2) {
+ goto error;
+ }
+
+ if (!(l_session = switch_core_session_locate(argv[0]))) {
+ stream->write_function(stream, "-ERR Usage: cannot locate session.\n");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (switch_is_number(argv[1])) {
+ tmp = atoi(argv[1]);
+ if (tmp > 0) {
+ seconds = tmp;
+ }
+ } else if (!switch_true(argv[1])) {
+ seconds = 0;
+ }
+
+ if (seconds) {
+ switch_core_session_enable_heartbeat(l_session, seconds);
+ } else {
+ switch_core_session_disable_heartbeat(l_session);
+ }
+
+ switch_core_session_rwunlock(l_session);
+
+ switch_safe_free(mycmd);
+ stream->write_function(stream, "+OK\n");
+ return SWITCH_STATUS_SUCCESS;
+
+ error:
+ switch_safe_free(mycmd);
+ stream->write_function(stream, "-ERR Usage: uuid_session_heartbeat %s", HEARTBEAT_SYNTAX);
+ return SWITCH_STATUS_SUCCESS;
+
+}
+
#define SETVAR_SYNTAX "<uuid> <var> <value>"
SWITCH_STANDARD_API(uuid_setvar_function)
{
@@ -2694,6 +2745,7 @@
switch_console_set_complete("add alias add");
switch_console_set_complete("add alias del");
SWITCH_ADD_API(commands_api_interface, "status", "status", status_function, "");
+ SWITCH_ADD_API(commands_api_interface, "uuid_session_heartbeat", "uuid_session_heartbeat", uuid_session_heartbeat_function, HEARTBEAT_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_bridge", "uuid_bridge", uuid_bridge_function, "");
SWITCH_ADD_API(commands_api_interface, "uuid_setvar", "uuid_setvar", uuid_setvar_function, SETVAR_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_getvar", "uuid_getvar", uuid_getvar_function, GETVAR_SYNTAX);
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Tue Oct 7 17:42:31 2008
@@ -1633,7 +1633,7 @@
if (switch_is_number(var)) {
tmp = atoi(var);
- if (tmp > 10) {
+ if (tmp > 0) {
seconds = tmp;
}
} else if (!switch_true(var)) {
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Tue Oct 7 17:42:31 2008
@@ -783,14 +783,21 @@
SWITCH_DECLARE(void) switch_core_session_enable_heartbeat(switch_core_session_t *session, uint32_t seconds)
{
switch_assert(session != NULL);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s setting session heartbeat to %u second(s).",
+
+ if (seconds < 10) {
+ seconds = 60;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s setting session heartbeat to %u second(s).\n",
switch_channel_get_name(session->channel), seconds);
session->track_duration = seconds;
+ session->read_frame_count = 0;
}
SWITCH_DECLARE(void) switch_core_session_disable_heartbeat(switch_core_session_t *session)
{
switch_assert(session != NULL);
+ session->read_frame_count = 0;
session->track_duration = 0;
}
More information about the Freeswitch-svn
mailing list