You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deathsyn edited this page Mar 10, 2011
·
1 revision
An Inbound Event Socket Listener example using FreeSWITCHeR’s hook system:
#!/usr/bin/rubyrequire'pp'require'fsr'require"fsr/listener/inbound"# EXAMPLE 1# This adds a hook on CHANNEL_CREATE events. You can also create a method to handle the event you're after. See the next exampleFSL::Inbound.add_event_hook(:CHANNEL_CREATE){FSR::Log.info"*** [#{event.content[:unique_id]}] Channel created - greetings from the hook!"}# EXAMPLE 2# Define a method to handle CHANNEL_HANGUP events.defcustom_channel_hangup_handler(event)FSR::Log.info"*** [#{event.content[:unique_id]}] Channel hangup. The event:"ppeventend# This adds a hook for EXAMPLE 2FSL::Inbound.add_event_hook(:CHANNEL_HANGUP){custom_channel_hangup_handler(event)}# Start FSR Inbound ListenerFSR.start_ies!(FSL::Inbound,:host=>"localhost",:port=>8021)
An Inbound Event Socket Listener example using the on_event callback method instead of hooks: