Class: FSR::Cmd::Sofia::Status

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

Constant Summary

Constants inherited from Command

Command::DEFAULT_OPTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Status.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fsr/cmd/sofia/status.rb', line 8

def initialize(fs_socket = nil, args = {})
  @fs_socket = fs_socket # FSR::CommandSocket object
  @status  = args[:status] # Status type; profile or gateway
  @name = args[:name] # Name of profile or gateway
  # If status is given, make sure it's profile or gateway
  unless @status.nil?
    raise "status must be profile or gateway" unless @status =~ /profile|gateway/i
  end
  if @status
    raise "must provide a profile or gateway name" unless @name
  end
end

Instance Attribute Details

#fs_socketObject (readonly)

Returns the value of attribute fs_socket.



6
7
8
# File 'lib/fsr/cmd/sofia/status.rb', line 6

def fs_socket
  @fs_socket
end

Instance Method Details

#rawObject

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



29
30
31
32
33
34
35
# File 'lib/fsr/cmd/sofia/status.rb', line 29

def raw
  if @status and @name
    orig_command = "sofia status #{@status} #{@name}"
  else
    orig_command = "sofia status"
  end
end

#run(api_method = :api) ⇒ Object

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



22
23
24
25
26
# File 'lib/fsr/cmd/sofia/status.rb', line 22

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