Class: Adhearsion::VoIP::FreeSwitch::InboundConnectionManager

Inherits:
BasicConnectionManager show all
Defined in:
lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb

Constant Summary collapse

DEFAULTS =
{ :pass => "ClueCon", :host => '127.0.0.1', :port => 8021 }

Instance Method Summary collapse

Methods inherited from BasicConnectionManager

#<<, #get_header, #get_raw_header, #next_event, #separate_pairs

Constructor Details

#initialize(arg) ⇒ InboundConnectionManager

Returns a new instance of InboundConnectionManager.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb', line 9

def initialize(arg)
  if arg.kind_of? Hash
    @opts = DEFAULTS.merge arg
    @io = TCPSocket.new(@opts[:host], @opts[:port])
    super @io
    unless (@opts[:pass])
      raise "Your FreeSwitch Event Socket password for #{@opts[:host]} was invalid!"
    end
  else arg.kind_of? IO
    @io = arg
    super @io
  end
end

Instance Method Details

#enable_events!(which = 'ALL') ⇒ Object



23
24
25
26
# File 'lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb', line 23

def enable_events!(which='ALL')
  self << "event plain #{which}"
  get_raw_header
end

#login(pass) ⇒ Object

Only called when nothing has been sent over the socket.



29
30
31
32
33
# File 'lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb', line 29

def (pass)
  get_raw_header
  self << "auth #{pass}"
  get_raw_header.include? "+OK"
end