switch_thread_rwlock_t *shutdown_rwlock;
/** if true, URI is put in from/to of offer if available */
int offer_uri;
+ /** if true, pause inbound calling if all clients are offline */
+ int pause_when_offline;
} globals;
/**
return component;
}
+/**
+ * @return true if at least one rayo client is online
+ */
+static int is_rayo_client_online(void)
+{
+ int is_online = 0;
+ switch_hash_index_t *hi;
+
+ switch_mutex_lock(globals.clients_mutex);
+
+ for (hi = switch_core_hash_first(globals.clients_roster); hi; hi = switch_core_hash_next(hi)) {
+ const void *key;
+ void *client;
+ switch_core_hash_this(hi, &key, NULL, &client);
+ switch_assert(client);
+ if (RAYO_CLIENT(client)->availability == PS_ONLINE) {
+ is_online = 1;
+ break;
+ }
+ }
+ switch_mutex_unlock(globals.clients_mutex);
+ return is_online;
+}
+
/**
* Send XMPP message to client
*/
}
}
switch_mutex_unlock(globals.clients_mutex);
+
+ if (globals.pause_when_offline && !is_rayo_client_online()) {
+ /* pause inbound calling */
+ int32_t arg = 1;
+ switch_core_session_ctl(SCSC_PAUSE_INBOUND, &arg);
+ }
}
/**
}
switch_mutex_unlock(globals.clients_mutex);
}
+
+ if (globals.pause_when_offline && is_rayo_client_online()) {
+ /* resume inbound calling */
+ int32_t arg = 0;
+ switch_core_session_ctl(SCSC_PAUSE_INBOUND, &arg);
+ }
+
return client;
}
RAYO_DESTROY(rclient);
RAYO_UNLOCK(rclient);
}
+
+ if (globals.pause_when_offline) {
+ if (is_rayo_client_online()) {
+ /* resume inbound calling */
+ int32_t arg = 0;
+ switch_core_session_ctl(SCSC_PAUSE_INBOUND, &arg);
+ } else {
+ /* pause inbound calling */
+ int32_t arg = 1;
+ switch_core_session_ctl(SCSC_PAUSE_INBOUND, &arg);
+ }
+ }
}
/**
globals.mixer_conf_profile = "sla";
globals.num_message_threads = 8;
globals.offer_uri = 1;
+ globals.pause_when_offline = 0;
/* get params */
{
if (switch_false(val)) {
globals.offer_uri = 0;
}
+ } else if (!strcasecmp(var, "pause-when-offline")) {
+ if (switch_true(val)) {
+ globals.pause_when_offline = 1;
+ }
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unsupported param: %s\n", var);
}