firing events from javascript - working example needed
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does? --Stephen
can you create a pastebin with the two scripts in question? We'll take a look and see if we can figure out what's going on. Thanks, MC On Tue, Jan 20, 2009 at 11:04 PM, Stephen Crosby <stevecrozz@gmail.com> wrote:
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does?
--Stephen
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Today I was able to see the event on the listener by subscribing to all events. But I'd like to only subscribe to a subset if possible. I thought that it would pop up when subscribing to CUSTOM events. I've put it all together very neatly here: http://pastebin.com/m6f8f7b43 --Stephen On Wed, Jan 21, 2009 at 6:03 AM, Michael Collins <msc@freeswitch.org> wrote:
can you create a pastebin with the two scripts in question? We'll take a look and see if we can figure out what's going on. Thanks, MC
On Tue, Jan 20, 2009 at 11:04 PM, Stephen Crosby <stevecrozz@gmail.com> wrote:
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does?
--Stephen
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
thanks we'll have a look. Also, please use pastebin.freeswitch.org in the future because it makes it easier for us to find things. :) -MC On Wed, Jan 21, 2009 at 8:53 AM, Stephen Crosby <stevecrozz@gmail.com> wrote:
Today I was able to see the event on the listener by subscribing to all events. But I'd like to only subscribe to a subset if possible. I thought that it would pop up when subscribing to CUSTOM events. I've put it all together very neatly here: http://pastebin.com/m6f8f7b43
--Stephen
On Wed, Jan 21, 2009 at 6:03 AM, Michael Collins <msc@freeswitch.org> wrote:
can you create a pastebin with the two scripts in question? We'll take a look and see if we can figure out what's going on. Thanks, MC
On Tue, Jan 20, 2009 at 11:04 PM, Stephen Crosby <stevecrozz@gmail.com> wrote:
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does?
--Stephen
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Stephen, I've been able to duplicate this behavior on my Mac with r11333. It seems to work with Lua but not with Javascript. I am going to discuss it with the devs and possibly open a jira issue. In the meantime would you be willing to try it with Lua, even just for testing? This worked for me: <lua script> -- Test sending custom events in Lua local event = freeswitch.Event("custom"); event:addHeader("Sample Custom Event", "no"); event:fire(); </lua script> I saved the above as /usr/local/freeswitch/scripts/event1.lua I then opened two terminal windows, one to freeswitch CLI and the other a telnet into the event socket On the event socket I logged in and listened for custom events: telnet localhost 8021 <enter> auth ClueCon <enter><enter> events plain custom <enter><enter> On FS CLI I typed: lua event1.lua <press enter> On the event socket I immediately see this: Sample Custom Event: no Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A14%3A35 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A14%3A35%20GMT Event-Date-Timestamp: 1232572475813346 Event-Calling-File: switch_cpp.cpp Event-Calling-Function: fire Event-Calling-Line-Number: 295 However, when I do the same kind of thing with js it doesn't work: <js script> // Sample event sent from JavaScript console_log("INFO","Starting event1.js sample event sender...\n"); var msg = "Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box"; e = new Event("custom", "message"); e.addBody(msg); e.fire(); </js script> I saved the above as /usr/local/freeswitch/scripts/event1.js I run it from the FS CLI: jsrun event1.js <enter> And I see my console message pop up but I don't see anything on the event socket However, if I do this at the event socket: events plain all <enter><enter> And then do jsrun event1.js from FS CLI then I do see my event on the event socket like this: Content-Length: 559 Content-Type: text/event-plain Event-Subclass: message Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A07%3A48 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A07%3A48%20GMT Event-Date-Timestamp: 1232572068370864 Event-Calling-File: mod_spidermonkey.c Event-Calling-Function: event_fire Event-Calling-Line-Number: 671 Content-Length: 90 Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box So, there's definitely something going on, we just need to find out what for sure. I'll be in touch. -MC (mercutioviz) On Wed, Jan 21, 2009 at 12:00 PM, Michael Collins <msc@freeswitch.org> wrote:
thanks we'll have a look. Also, please use pastebin.freeswitch.org in the future because it makes it easier for us to find things. :) -MC
On Wed, Jan 21, 2009 at 8:53 AM, Stephen Crosby <stevecrozz@gmail.com> wrote:
Today I was able to see the event on the listener by subscribing to all events. But I'd like to only subscribe to a subset if possible. I thought that it would pop up when subscribing to CUSTOM events. I've put it all together very neatly here: http://pastebin.com/m6f8f7b43
--Stephen
On Wed, Jan 21, 2009 at 6:03 AM, Michael Collins <msc@freeswitch.org> wrote:
can you create a pastebin with the two scripts in question? We'll take a look and see if we can figure out what's going on. Thanks, MC
On Tue, Jan 20, 2009 at 11:04 PM, Stephen Crosby <stevecrozz@gmail.com> wrote:
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does?
--Stephen
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Sure, I'll give it a try when I get home. On Wed, Jan 21, 2009 at 1:43 PM, Michael Collins <msc@freeswitch.org> wrote:
Stephen,
I've been able to duplicate this behavior on my Mac with r11333. It seems to work with Lua but not with Javascript. I am going to discuss it with the devs and possibly open a jira issue. In the meantime would you be willing to try it with Lua, even just for testing? This worked for me: <lua script> -- Test sending custom events in Lua local event = freeswitch.Event("custom"); event:addHeader("Sample Custom Event", "no"); event:fire(); </lua script> I saved the above as /usr/local/freeswitch/scripts/event1.lua
I then opened two terminal windows, one to freeswitch CLI and the other a telnet into the event socket On the event socket I logged in and listened for custom events: telnet localhost 8021 <enter> auth ClueCon <enter><enter> events plain custom <enter><enter>
On FS CLI I typed: lua event1.lua <press enter>
On the event socket I immediately see this: Sample Custom Event: no Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A14%3A35 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A14%3A35%20GMT Event-Date-Timestamp: 1232572475813346 Event-Calling-File: switch_cpp.cpp Event-Calling-Function: fire Event-Calling-Line-Number: 295
However, when I do the same kind of thing with js it doesn't work: <js script> // Sample event sent from JavaScript console_log("INFO","Starting event1.js sample event sender...\n"); var msg = "Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box"; e = new Event("custom", "message"); e.addBody(msg); e.fire(); </js script>
I saved the above as /usr/local/freeswitch/scripts/event1.js I run it from the FS CLI: jsrun event1.js <enter> And I see my console message pop up but I don't see anything on the event socket However, if I do this at the event socket: events plain all <enter><enter>
And then do jsrun event1.js from FS CLI then I do see my event on the event socket like this: Content-Length: 559 Content-Type: text/event-plain
Event-Subclass: message Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A07%3A48 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A07%3A48%20GMT Event-Date-Timestamp: 1232572068370864 Event-Calling-File: mod_spidermonkey.c Event-Calling-Function: event_fire Event-Calling-Line-Number: 671 Content-Length: 90
Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box
So, there's definitely something going on, we just need to find out what for sure. I'll be in touch. -MC (mercutioviz)
On Wed, Jan 21, 2009 at 12:00 PM, Michael Collins <msc@freeswitch.org> wrote:
thanks we'll have a look. Also, please use pastebin.freeswitch.org in the future because it makes it easier for us to find things. :) -MC
On Wed, Jan 21, 2009 at 8:53 AM, Stephen Crosby <stevecrozz@gmail.com> wrote:
Today I was able to see the event on the listener by subscribing to all events. But I'd like to only subscribe to a subset if possible. I thought that it would pop up when subscribing to CUSTOM events. I've put it all together very neatly here: http://pastebin.com/m6f8f7b43
--Stephen
On Wed, Jan 21, 2009 at 6:03 AM, Michael Collins <msc@freeswitch.org> wrote:
can you create a pastebin with the two scripts in question? We'll take a look and see if we can figure out what's going on. Thanks, MC
On Tue, Jan 20, 2009 at 11:04 PM, Stephen Crosby <stevecrozz@gmail.com> wrote:
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does?
--Stephen
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
RESOLVED! Stephen, when using event sub-classes you need to specify the subclass when subscribing to listen to the events. I added a small entry to the wiki page that I hope makes it clear: http://wiki.freeswitch.org/wiki/Javascript_Event#Subscribing_To_Custom_Event... Let me know if you have any more questions. -MC P.S. - I will follow up with Lua and Perl and make sure that the wiki is clear on how to subscribe to events. it looks like the default for Lua is not to have an event subclass but the default for JavaScript does have an event subclass... :) On Wed, Jan 21, 2009 at 1:49 PM, Stephen Crosby <stevecrozz@gmail.com> wrote:
Sure, I'll give it a try when I get home.
On Wed, Jan 21, 2009 at 1:43 PM, Michael Collins <msc@freeswitch.org> wrote:
Stephen,
I've been able to duplicate this behavior on my Mac with r11333. It seems to work with Lua but not with Javascript. I am going to discuss it with the devs and possibly open a jira issue. In the meantime would you be willing to try it with Lua, even just for testing? This worked for me: <lua script> -- Test sending custom events in Lua local event = freeswitch.Event("custom"); event:addHeader("Sample Custom Event", "no"); event:fire(); </lua script> I saved the above as /usr/local/freeswitch/scripts/event1.lua
I then opened two terminal windows, one to freeswitch CLI and the other a telnet into the event socket On the event socket I logged in and listened for custom events: telnet localhost 8021 <enter> auth ClueCon <enter><enter> events plain custom <enter><enter>
On FS CLI I typed: lua event1.lua <press enter>
On the event socket I immediately see this: Sample Custom Event: no Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A14%3A35 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A14%3A35%20GMT Event-Date-Timestamp: 1232572475813346 Event-Calling-File: switch_cpp.cpp Event-Calling-Function: fire Event-Calling-Line-Number: 295
However, when I do the same kind of thing with js it doesn't work: <js script> // Sample event sent from JavaScript console_log("INFO","Starting event1.js sample event sender...\n"); var msg = "Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box"; e = new Event("custom", "message"); e.addBody(msg); e.fire(); </js script>
I saved the above as /usr/local/freeswitch/scripts/event1.js I run it from the FS CLI: jsrun event1.js <enter> And I see my console message pop up but I don't see anything on the event socket However, if I do this at the event socket: events plain all <enter><enter>
And then do jsrun event1.js from FS CLI then I do see my event on the event socket like this: Content-Length: 559 Content-Type: text/event-plain
Event-Subclass: message Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A07%3A48 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A07%3A48%20GMT Event-Date-Timestamp: 1232572068370864 Event-Calling-File: mod_spidermonkey.c Event-Calling-Function: event_fire Event-Calling-Line-Number: 671 Content-Length: 90
Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box
So, there's definitely something going on, we just need to find out what for sure. I'll be in touch. -MC (mercutioviz)
On Wed, Jan 21, 2009 at 12:00 PM, Michael Collins <msc@freeswitch.org> wrote:
thanks we'll have a look. Also, please use pastebin.freeswitch.org in the future because it makes it easier for us to find things. :) -MC
On Wed, Jan 21, 2009 at 8:53 AM, Stephen Crosby <stevecrozz@gmail.com> wrote:
Today I was able to see the event on the listener by subscribing to all events. But I'd like to only subscribe to a subset if possible. I thought that it would pop up when subscribing to CUSTOM events. I've put it all together very neatly here: http://pastebin.com/m6f8f7b43
--Stephen
On Wed, Jan 21, 2009 at 6:03 AM, Michael Collins <msc@freeswitch.org> wrote:
can you create a pastebin with the two scripts in question? We'll take a look and see if we can figure out what's going on. Thanks, MC
On Tue, Jan 20, 2009 at 11:04 PM, Stephen Crosby <stevecrozz@gmail.com> wrote:
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does?
--Stephen
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
lua: local event = freeswitch.Event("custom"); js: e = new Event("custom", "message"); in js you specify a subclass which means you would need to subscribe to it events plain custom message really just events plain custom is not a good idea because all the real events have a subclass once the custom keyword is seen in the event command each name after that is assumed to be a custom event name. For subclass we use the naming convention mod::event_name so a better test would be: e = new Event("custom", "my_js::test"); there is no point to specify a subclass unless the event type is custom. e = new Event("message"); would be a better example because you can easily subscribe to the "message" event. On Wed, Jan 21, 2009 at 3:43 PM, Michael Collins <msc@freeswitch.org> wrote:
Stephen,
I've been able to duplicate this behavior on my Mac with r11333. It seems to work with Lua but not with Javascript. I am going to discuss it with the devs and possibly open a jira issue. In the meantime would you be willing to try it with Lua, even just for testing? This worked for me: <lua script> -- Test sending custom events in Lua local event = freeswitch.Event("custom"); event:addHeader("Sample Custom Event", "no"); event:fire(); </lua script> I saved the above as /usr/local/freeswitch/scripts/event1.lua
I then opened two terminal windows, one to freeswitch CLI and the other a telnet into the event socket On the event socket I logged in and listened for custom events: telnet localhost 8021 <enter> auth ClueCon <enter><enter> events plain custom <enter><enter>
On FS CLI I typed: lua event1.lua <press enter>
On the event socket I immediately see this: Sample Custom Event: no Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A14%3A35 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A14%3A35%20GMT Event-Date-Timestamp: 1232572475813346 Event-Calling-File: switch_cpp.cpp Event-Calling-Function: fire Event-Calling-Line-Number: 295
However, when I do the same kind of thing with js it doesn't work: <js script> // Sample event sent from JavaScript console_log("INFO","Starting event1.js sample event sender...\n"); var msg = "Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box"; e = new Event("custom", "message"); e.addBody(msg); e.fire(); </js script>
I saved the above as /usr/local/freeswitch/scripts/event1.js I run it from the FS CLI: jsrun event1.js <enter> And I see my console message pop up but I don't see anything on the event socket However, if I do this at the event socket: events plain all <enter><enter>
And then do jsrun event1.js from FS CLI then I do see my event on the event socket like this: Content-Length: 559 Content-Type: text/event-plain
Event-Subclass: message Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A07%3A48 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A07%3A48%20GMT Event-Date-Timestamp: 1232572068370864 Event-Calling-File: mod_spidermonkey.c Event-Calling-Function: event_fire Event-Calling-Line-Number: 671 Content-Length: 90
Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box
So, there's definitely something going on, we just need to find out what for sure. I'll be in touch. -MC (mercutioviz)
On Wed, Jan 21, 2009 at 12:00 PM, Michael Collins <msc@freeswitch.org> wrote:
thanks we'll have a look. Also, please use pastebin.freeswitch.org in the future because it makes it easier for us to find things. :) -MC
On Wed, Jan 21, 2009 at 8:53 AM, Stephen Crosby <stevecrozz@gmail.com> wrote:
Today I was able to see the event on the listener by subscribing to all events. But I'd like to only subscribe to a subset if possible. I thought that it would pop up when subscribing to CUSTOM events. I've put it all together very neatly here: http://pastebin.com/m6f8f7b43
--Stephen
On Wed, Jan 21, 2009 at 6:03 AM, Michael Collins <msc@freeswitch.org> wrote:
can you create a pastebin with the two scripts in question? We'll take a look and see if we can figure out what's going on. Thanks, MC
On Tue, Jan 20, 2009 at 11:04 PM, Stephen Crosby <stevecrozz@gmail.com> wrote:
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does?
--Stephen
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
Anthm, I will add the substance of this to the wiki. -MC Sent from my iPhone On Jan 21, 2009, at 2:09 PM, Anthony Minessale <anthony.minessale@gmail.com
wrote:
lua:
local event = freeswitch.Event("custom");
js: e = new Event("custom", "message");
in js you specify a subclass which means you would need to subscribe to it events plain custom message
really just events plain custom is not a good idea because all the real events have a subclass once the custom keyword is seen in the event command each name after that is assumed to be a custom event name.
For subclass we use the naming convention mod::event_name so a better test would be:
e = new Event("custom", "my_js::test");
there is no point to specify a subclass unless the event type is custom.
e = new Event("message");
would be a better example because you can easily subscribe to the "message" event.
On Wed, Jan 21, 2009 at 3:43 PM, Michael Collins <msc@freeswitch.org> wrote: Stephen,
I've been able to duplicate this behavior on my Mac with r11333. It seems to work with Lua but not with Javascript. I am going to discuss it with the devs and possibly open a jira issue. In the meantime would you be willing to try it with Lua, even just for testing? This worked for me: <lua script> -- Test sending custom events in Lua local event = freeswitch.Event("custom"); event:addHeader("Sample Custom Event", "no"); event:fire(); </lua script> I saved the above as /usr/local/freeswitch/scripts/event1.lua
I then opened two terminal windows, one to freeswitch CLI and the other a telnet into the event socket On the event socket I logged in and listened for custom events: telnet localhost 8021 <enter> auth ClueCon <enter><enter> events plain custom <enter><enter>
On FS CLI I typed: lua event1.lua <press enter>
On the event socket I immediately see this: Sample Custom Event: no Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A14%3A35 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A14%3A35%20GMT Event-Date-Timestamp: 1232572475813346 Event-Calling-File: switch_cpp.cpp Event-Calling-Function: fire Event-Calling-Line-Number: 295
However, when I do the same kind of thing with js it doesn't work: <js script> // Sample event sent from JavaScript console_log("INFO","Starting event1.js sample event sender...\n"); var msg = "Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box"; e = new Event("custom", "message"); e.addBody(msg); e.fire(); </js script>
I saved the above as /usr/local/freeswitch/scripts/event1.js I run it from the FS CLI: jsrun event1.js <enter> And I see my console message pop up but I don't see anything on the event socket However, if I do this at the event socket: events plain all <enter><enter>
And then do jsrun event1.js from FS CLI then I do see my event on the event socket like this: Content-Length: 559 Content-Type: text/event-plain
Event-Subclass: message Event-Name: CUSTOM Core-UUID: 2c04a36e-5a23-4b14-b0a5-34fe9fd9f1bc FreeSWITCH-Hostname: michael-collinss-macbook-pro.local FreeSWITCH-IPv4: 192.168.1.5 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2009-01-21%2013%3A07%3A48 Event-Date-GMT: Wed,%2021%20Jan%202009%2021%3A07%3A48%20GMT Event-Date-Timestamp: 1232572068370864 Event-Calling-File: mod_spidermonkey.c Event-Calling-Function: event_fire Event-Calling-Line-Number: 671 Content-Length: 90
Hello, welcome to the FreeSWITCH demo application please enter some text into the chat box
So, there's definitely something going on, we just need to find out what for sure. I'll be in touch. -MC (mercutioviz)
On Wed, Jan 21, 2009 at 12:00 PM, Michael Collins <msc@freeswitch.org> wrote:
thanks we'll have a look. Also, please use pastebin.freeswitch.org in the future because it makes it easier for us to find things. :) -MC
On Wed, Jan 21, 2009 at 8:53 AM, Stephen Crosby <stevecrozz@gmail.com wrote:
Today I was able to see the event on the listener by subscribing to all events. But I'd like to only subscribe to a subset if possible. I thought that it would pop up when subscribing to CUSTOM events. I've put it all together very neatly here: http://pastebin.com/m6f8f7b43
--Stephen
On Wed, Jan 21, 2009 at 6:03 AM, Michael Collins <msc@freeswitch.org wrote:
can you create a pastebin with the two scripts in question? We'll take a look and see if we can figure out what's going on. Thanks, MC
On Tue, Jan 20, 2009 at 11:04 PM, Stephen Crosby <stevecrozz@gmail.com wrote:
I noticed the wiki has an example of sending a custom event from javascript: http://wiki.freeswitch.org/wiki/Javascript_Event , but I can't make it work. It doesn't fail or cause an error. But I never see an event on my listener script. Can someone confirm that this example does in fact work? or provide me with one that does?
--Stephen
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II
FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/
AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org pstn:213-799-1400 _______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (4)
-
Anthony Minessale
-
Michael Collins
-
Michael S Collins
-
Stephen Crosby