[Freeswitch-svn] [commit] r10110 - freeswitch/trunk/src/mod/event_handlers/mod_event_socket
Freeswitch SVN
anthm at freeswitch.org
Wed Oct 22 12:32:56 EDT 2008
Author: anthm
Date: Wed Oct 22 12:32:55 2008
New Revision: 10110
Modified:
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
Log:
inbound connection to event_socket can now take over an existing channel with 'myevents <uuid>' to take on the behaviour of an outbound socket
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Wed Oct 22 12:32:55 2008
@@ -743,8 +743,12 @@
}
- if (listener->session) {
- switch_channel_t *channel = switch_core_session_get_channel(listener->session);
+ if (listener->session || !strncasecmp(cmd, "myevents ", 9)) {
+ switch_channel_t *channel = NULL;
+
+ if (listener->session) {
+ channel = switch_core_session_get_channel(listener->session);
+ }
if (!strncasecmp(cmd, "connect", 7)) {
switch_snprintf(reply, reply_len, "+OK");
@@ -777,6 +781,29 @@
switch_snprintf(reply, reply_len, "%s", val);
goto done;
} else if (!strncasecmp(cmd, "myevents", 8)) {
+ if (switch_test_flag(listener, LFLAG_MYEVENTS)) {
+ switch_snprintf(reply, reply_len, "-ERR aready enabled.");
+ goto done;
+ }
+
+ if (!listener->session) {
+ char *uuid;
+
+ if ((uuid = cmd + 9)) {
+ strip_cr(uuid);
+
+ if (!(listener->session = switch_core_session_locate(uuid))) {
+ switch_snprintf(reply, reply_len, "-ERR invalid uuid");
+ goto done;
+ }
+
+ switch_set_flag_locked(listener, LFLAG_SESSION);
+ switch_set_flag_locked(listener, LFLAG_ASYNC);
+ }
+
+
+ }
+
listener->event_list[SWITCH_EVENT_CHANNEL_CREATE] = 1;
listener->event_list[SWITCH_EVENT_CHANNEL_DESTROY] = 1;
listener->event_list[SWITCH_EVENT_CHANNEL_STATE] = 1;
@@ -1314,10 +1341,10 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Closed\n");
switch_core_hash_destroy(&listener->event_hash);
- if (session) {
- switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED);
+ if (listener->session) {
+ switch_channel_clear_flag(switch_core_session_get_channel(listener->session), CF_CONTROLLED);
switch_clear_flag_locked(listener, LFLAG_SESSION);
- switch_core_session_rwunlock(session);
+ switch_core_session_rwunlock(listener->session);
} else if (listener->pool) {
switch_memory_pool_t *pool = listener->pool;
switch_core_destroy_memory_pool(&pool);
More information about the Freeswitch-svn
mailing list