Class: FSR::Cmd::UuidSendDtmf

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

Constant Summary

Constants inherited from Command

Command::DEFAULT_OPTIONS

Instance Method Summary collapse

Constructor Details

#initialize(fs_socket = nil, args = {}) ⇒ UuidSendDtmf

Returns a new instance of UuidSendDtmf.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
# File 'lib/fsr/cmd/uuid_send_dtmf.rb', line 6

def initialize(fs_socket = nil, args = {})
  @fs_socket = fs_socket # FSR::CommandSocket obj
  @uuid, dtmf = args.values_at(:uuid, :dtmf)
  raise(ArgumentError, "No uuid given") unless @uuid
  raise(ArgumentError, "No dtmf data given") unless dtmf
  @dtmf = FSR::Utils::DTMF.from_string(dtmf)
end

Instance Method Details

#rawObject

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



22
23
24
# File 'lib/fsr/cmd/uuid_send_dtmf.rb', line 22

def raw
  "uuid_send_dtmf #{@uuid} #{@dtmf}"
end

#run(api_method = :api) ⇒ Object

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



15
16
17
18
19
# File 'lib/fsr/cmd/uuid_send_dtmf.rb', line 15

def run(api_method = :api)
  orig_command = "%s %s" % [api_method, raw]
  Log.debug "saying #{orig_command}"
  @fs_socket.say(orig_command)
end