forked from bougyman/freeswitcher
-
Notifications
You must be signed in to change notification settings - Fork 11
Inboundevent
deathsyn edited this page Mar 10, 2011
·
1 revision
#!/usr/bin/ruby
require '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 example
FSL::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.
def custom_channel_hangup_handler(event)
FSR::Log.info "*** [#{event.content[:unique_id]}] Channel hangup. The event:"
pp event
end
# This adds a hook for EXAMPLE 2
FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) { custom_channel_hangup_handler(event) }
# Start FSR Inbound Listener
FSR.start_ies!(FSL::Inbound, :host => "localhost", :port => 8021)
#!/usr/bin/ruby
require 'pp'
require 'fsr'
require "fsr/listener/inbound"
class IesDemo < FSR::Listener::Inbound
def on_event
pp event.headers
pp event.content[:event_name]
end
end
FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021, :auth => "ClueCon")