please shed me light on code reading
hi, Any expert can shed me some light on quick code understanding? thanks in advance! suppose I dial 88<1001> to spy on extension user 1001. and 5 minutes later 1001 calls 1002. <extension name="userspy"> <condition field="destination_number" expression="^88(.*)$|^\*0(.*)$"> <action application="answer"/> <action application="userspy" data="$1@192.168.1.1"/> </condition> </extension> in event_handle(...) of mod_spy.c. -- Whats is the reason that we need to call process_event for both event and peer_event? is not processing event for call leg-a 's bridge enough? it seems mod_spy.c in 1.0.6 version doesn't process peer_event. static void event_handler(switch_event_t *event) { if (process_event(event) != SWITCH_STATUS_SUCCESS) { const char *peer_uuid = switch_event_get_header(event, "variable_signal_bond"); ... if (peer_event) { process_event(peer_event); } } } http://svn.freeswitch.org/svn/freeswitch/trunk/src/mod/applications/mod_spy/...
one more question. switch_channel_set_variable(channel, "spy_uuid", my_uuid); switch_channel_set_private(channel, "_userspy_", (void *) argv[0]); why one is set via rugular variable and one is set via private? is that necessary? -jesse On Sat, Nov 20, 2010 at 10:48 PM, jesse <chat2jesse@gmail.com> wrote:
hi,
Any expert can shed me some light on quick code understanding? thanks in advance!
suppose I dial 88<1001> to spy on extension user 1001. and 5 minutes later 1001 calls 1002.
<extension name="userspy"> <condition field="destination_number" expression="^88(.*)$|^\*0(.*)$"> <action application="answer"/> <action application="userspy" data="$1@192.168.1.1"/> </condition> </extension>
in event_handle(...) of mod_spy.c. -- Whats is the reason that we need to call process_event for both event and peer_event? is not processing event for call leg-a 's bridge enough? it seems mod_spy.c in 1.0.6 version doesn't process peer_event.
static void event_handler(switch_event_t *event) { if (process_event(event) != SWITCH_STATUS_SUCCESS) { const char *peer_uuid = switch_event_get_header(event, "variable_signal_bond"); ... if (peer_event) { process_event(peer_event); } } }
http://svn.freeswitch.org/svn/freeswitch/trunk/src/mod/applications/mod_spy/...
a variable is a channel variable that you can access in the dial-plan, in events, etc. A private is a void pointer that we use to store data that is later accessed by name in the application. The code you were talking about below was added to support loopback channel: commit d0a74dd5c445e8a1540ba0a3f465ad394e033193 Date: Mon Apr 26 04:30:10 2010 -0400 mod_spy: add support for loopback endpoint (MODAPP-416) Mike On Nov 21, 2010, at 2:36 AM, jesse wrote:
one more question.
switch_channel_set_variable(channel, "spy_uuid", my_uuid); switch_channel_set_private(channel, "_userspy_", (void *) argv[0]);
why one is set via rugular variable and one is set via private? is that necessary?
-jesse
On Sat, Nov 20, 2010 at 10:48 PM, jesse <chat2jesse@gmail.com> wrote:
hi,
Any expert can shed me some light on quick code understanding? thanks in advance!
suppose I dial 88<1001> to spy on extension user 1001. and 5 minutes later 1001 calls 1002.
<extension name="userspy"> <condition field="destination_number" expression="^88(.*)$|^\*0(.*)$"> <action application="answer"/> <action application="userspy" data="$1@192.168.1.1"/> </condition> </extension>
in event_handle(...) of mod_spy.c. -- Whats is the reason that we need to call process_event for both event and peer_event? is not processing event for call leg-a 's bridge enough? it seems mod_spy.c in 1.0.6 version doesn't process peer_event.
static void event_handler(switch_event_t *event) { if (process_event(event) != SWITCH_STATUS_SUCCESS) { const char *peer_uuid = switch_event_get_header(event, "variable_signal_bond"); ... if (peer_event) { process_event(peer_event); } } }
http://svn.freeswitch.org/svn/freeswitch/trunk/src/mod/applications/mod_spy/...
_______________________________________________ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Michael, my question is more more specific like : Can we use : switch_channel_set_variable(channel, "_userspy_", (void *) argv[0]); instead of using private? It seems this should serve the same purpose. thus, I don't see a reason why one is using private, the other is using variable. thanks for pointing out the code process_event is used to support loopback. I still couldn't figure out why the process_event won't work on call leg-a, but it will work on call leg-b in the case of loop back? please illustrate me. just one general observation, FS source code really lacks code comments, it takes tremendous effort to understand the code. FS dev community should enforce developer to add more comments for business logic for readability. This is going to help FS down the road in terms of sustaining, adapting, and feature enriching. -jesse On Tue, Nov 23, 2010 at 6:39 AM, Michael Jerris <mike@jerris.com> wrote:
a variable is a channel variable that you can access in the dial-plan, in events, etc. A private is a void pointer that we use to store data that is later accessed by name in the application. The code you were talking about below was added to support loopback channel:
commit d0a74dd5c445e8a1540ba0a3f465ad394e033193 Date: Mon Apr 26 04:30:10 2010 -0400 mod_spy: add support for loopback endpoint (MODAPP-416)
Mike
On Nov 21, 2010, at 2:36 AM, jesse wrote:
one more question.
switch_channel_set_variable(channel, "spy_uuid", my_uuid); switch_channel_set_private(channel, "_userspy_", (void *) argv[0]);
why one is set via rugular variable and one is set via private? is that necessary?
-jesse
On Sat, Nov 20, 2010 at 10:48 PM, jesse <chat2jesse@gmail.com> wrote:
hi,
Any expert can shed me some light on quick code understanding? thanks in advance!
suppose I dial 88<1001> to spy on extension user 1001. and 5 minutes later 1001 calls 1002.
<extension name="userspy"> <condition field="destination_number" expression="^88(.*)$|^\*0(.*)$"> <action application="answer"/> <action application="userspy" data="$1@192.168.1.1"/> </condition> </extension>
in event_handle(...) of mod_spy.c. -- Whats is the reason that we need to call process_event for both event and peer_event? is not processing event for call leg-a 's bridge enough? it seems mod_spy.c in 1.0.6 version doesn't process peer_event.
static void event_handler(switch_event_t *event) { if (process_event(event) != SWITCH_STATUS_SUCCESS) { const char *peer_uuid = switch_event_get_header(event, "variable_signal_bond"); ... if (peer_event) { process_event(peer_event); } } }
http://svn.freeswitch.org/svn/freeswitch/trunk/src/mod/applications/mod_spy/...
_______________________________________________ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
_______________________________________________ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Hi, switch_channel_set_variable() is limited to saving strings, if you want to save other data structures, you have to use switch_channel_set_private(). Mathieu Rene Avant-Garde Solutions Inc Office: + 1 (514) 664-1044 x100 Cell: +1 (514) 664-1044 x200 mrene@avgs.ca On 2010-11-23, at 10:56 PM, jesse wrote:
Michael,
my question is more more specific like : Can we use : switch_channel_set_variable(channel, "_userspy_", (void *) argv[0]); instead of using private? It seems this should serve the same purpose. thus, I don't see a reason why one is using private, the other is using variable.
thanks for pointing out the code process_event is used to support loopback. I still couldn't figure out why the process_event won't work on call leg-a, but it will work on call leg-b in the case of loop back? please illustrate me.
just one general observation, FS source code really lacks code comments, it takes tremendous effort to understand the code. FS dev community should enforce developer to add more comments for business logic for readability. This is going to help FS down the road in terms of sustaining, adapting, and feature enriching.
-jesse
On Tue, Nov 23, 2010 at 6:39 AM, Michael Jerris <mike@jerris.com> wrote:
a variable is a channel variable that you can access in the dial-plan, in events, etc. A private is a void pointer that we use to store data that is later accessed by name in the application. The code you were talking about below was added to support loopback channel:
commit d0a74dd5c445e8a1540ba0a3f465ad394e033193 Date: Mon Apr 26 04:30:10 2010 -0400 mod_spy: add support for loopback endpoint (MODAPP-416)
Mike
On Nov 21, 2010, at 2:36 AM, jesse wrote:
one more question.
switch_channel_set_variable(channel, "spy_uuid", my_uuid); switch_channel_set_private(channel, "_userspy_", (void *) argv[0]);
why one is set via rugular variable and one is set via private? is that necessary?
-jesse
On Sat, Nov 20, 2010 at 10:48 PM, jesse <chat2jesse@gmail.com> wrote:
hi,
Any expert can shed me some light on quick code understanding? thanks in advance!
suppose I dial 88<1001> to spy on extension user 1001. and 5 minutes later 1001 calls 1002.
<extension name="userspy"> <condition field="destination_number" expression="^88(.*)$|^\*0(.*)$"> <action application="answer"/> <action application="userspy" data="$1@192.168.1.1"/> </condition> </extension>
in event_handle(...) of mod_spy.c. -- Whats is the reason that we need to call process_event for both event and peer_event? is not processing event for call leg-a 's bridge enough? it seems mod_spy.c in 1.0.6 version doesn't process peer_event.
static void event_handler(switch_event_t *event) { if (process_event(event) != SWITCH_STATUS_SUCCESS) { const char *peer_uuid = switch_event_get_header(event, "variable_signal_bond"); ... if (peer_event) { process_event(peer_event); } } }
http://svn.freeswitch.org/svn/freeswitch/trunk/src/mod/applications/mod_spy/...
_______________________________________________ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
_______________________________________________ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
_______________________________________________ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
From a quick peek at the code, I can state the obvious: process(peer_event) is only called when process(event) has failed. So, process_event will be called for event or peer_event (not both). I can think of a scenario where this might happen (this is an educated guess, though): If channels A and B bridged and A hangs up. A receives a CHANNEL_HANGUP and channel B must receive a CHANNEL_UNBRIDGE (from channel A) event, so that it can take appropriate actions (like hang up too or go back to an IVR menu). Regards, Paulo. On 21/11/10 01:48, jesse wrote:
hi,
Any expert can shed me some light on quick code understanding? thanks in advance!
suppose I dial 88<1001> to spy on extension user 1001. and 5 minutes later 1001 calls 1002.
<extension name="userspy"> <condition field="destination_number" expression="^88(.*)$|^\*0(.*)$"> <action application="answer"/> <action application="userspy" data="$1@192.168.1.1"/> </condition> </extension>
in event_handle(...) of mod_spy.c. -- Whats is the reason that we need to call process_event for both event and peer_event? is not processing event for call leg-a 's bridge enough? it seems mod_spy.c in 1.0.6 version doesn't process peer_event.
static void event_handler(switch_event_t *event) { if (process_event(event) != SWITCH_STATUS_SUCCESS) { const char *peer_uuid = switch_event_get_header(event, "variable_signal_bond"); ... if (peer_event) { process_event(peer_event); } } }
http://svn.freeswitch.org/svn/freeswitch/trunk/src/mod/applications/mod_spy/...
_______________________________________________ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
participants (4)
-
jesse
-
Mathieu Rene
-
Michael Jerris
-
Paulo Rogério Panhoto