Class: FSR::Cmd::SofiaContact

Inherits:
Command
  • Object
show all
Defined in:
lib/fsr/cmd/sofia_contact.rb

Constant Summary

Constants inherited from Command

Command::DEFAULT_OPTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fs_socket = nil, contact = {}) ⇒ SofiaContact

Returns a new instance of SofiaContact.



10
11
12
13
14
# File 'lib/fsr/cmd/sofia_contact.rb', line 10

def initialize(fs_socket = nil, contact = {})
  @fs_socket = fs_socket # FSR::CommandSocket obj
  @contact = contact[:contact]
  #puts @contact
end

Instance Attribute Details

#contactObject (readonly)

Returns the value of attribute contact.



8
9
10
# File 'lib/fsr/cmd/sofia_contact.rb', line 8

def contact
  @contact
end

Instance Method Details

#rawObject

This method builds the API command to send to the freeswitch event socket



25
26
27
# File 'lib/fsr/cmd/sofia_contact.rb', line 25

def raw
  orig_command = "sofia_contact #{@contact}"
end

#run(api_method = :api) ⇒ Object

Send the command to the event socket, using api by default.



17
18
19
20
21
22
# File 'lib/fsr/cmd/sofia_contact.rb', line 17

def run(api_method = :api)
  orig_command = "%s %s" % [api_method, raw]
  Log.debug "saying #{orig_command}"
  resp = @fs_socket.say(orig_command)
  resp["body"].match(%r{^error/}) ? nil : resp["body"]
end