[Freeswitch-users] sending custom events from event_socket, channel_variable_changed event?

Benedikt Fraunhofer fraunhofer.lists.freeswitch-001 at traced.net
Tue Sep 15 10:08:37 PDT 2009


Hello *,

while trying to figure out how to send custom events from mod_socket
with "sendmsg" (like a telnet connection or something) i only found
how to do that from within javascript (with e.fire() and stuff).

So... first of all, how's the correct syntax to do that from the
event_socket? the wiki states
---
  sendmsg <uuid>

  Send a message to the call of given uuid (call-command execute or
hangup), see examples
  below.
---


Is there a secret syntax i missed how to send "CUSTOM" events?

I tried to work-around that by setting a channel-variable and then
calling the info-app. That way, a channel_execute event is fired and
shows up in my event_socket-app.
If there's a prettier way... please ignore the following up to the
<snipp> mark :)

so it looked to me that i can only send "command" messages and looking
at the sources i found that mod_socket will hard-wire the event-name
to "SWITCH_EVENT_COMMAND" (in read_packet() in
./mod/event_handlers/mod_event_socket/mod_event_socket.c). If i
understand correctly how e.g.. the mod_spidermonkey-bindings enqueue
events, the event-name is taken from the user and can therefor be
"CUSTOM" (looks like it's being looked up in the
switch_event_types_t-enum).
---
                        if (switch_name_event(ename, &etype) !=
SWITCH_STATUS_SUCCESS) {
                                switch_log_printf(SWITCH_CHANNEL_LOG,
SWITCH_LOG_WARNING, "Unknown event %s\n", ename);
                                *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
                                return JS_TRUE;
                        }

                        if (etype == SWITCH_EVENT_CUSTOM) {
[...]
 if (switch_event_create_subclass(&event, etype, subclass_name) !=
SWITCH_STATUS_SUCCESS) {

---


If it's currently not possible, do you think this could be useful, too?
I thought a bit about the syntax and came up with this idea to not
break compatibility, but feel free to change that, you know it better
:)
if you want to send an event that's not COMMAND, use "event-name:
CUSTOM" as the first line after the "sendmsg [uuid]" and change the
event-name (if that's possible) of the event already created by
read_packet() or reconstruct the event or ...

<snipp>

Just another idea..... that could become handy is if there would be an
event "CHANNEL_VAR_CHANGED", fired/enqueued by setvar(),
setvar_multi() and friends. But as i write this i admit that one will
be overwhelmed by the setvar massacre for example bridge() would do to
set "disposition"-variables... Just a thought.

Cheers
  Beni.




More information about the FreeSWITCH-users mailing list