Module: Librevox::Commands

Included in:
CommandSocket, Listener::Base::CommandDelegate
Defined in:
lib/librevox/commands.rb

Overview

All commands should call `command` with the following parameters:

`name` - name of the command
`args` - arguments as a string (optional)

Commands must pass on any eventual block passed to them.

Instance Method Summary collapse

Instance Method Details

#command(name, args = "") ⇒ Object

Executes a generic API command, optionally taking arguments as string.

Examples:

socket.command "fsctl", "hupall normal_clearing"

See Also:



13
14
15
16
17
# File 'lib/librevox/commands.rb', line 13

def command name, args=""
  msg = "api #{name}"
  msg << " #{args}" if args && !args.empty?
  msg
end

#fsctl(*args, &block) ⇒ Object

FreeSWITCH control messages.

Examples:

socket.fsctl :hupall, :normal_clearing

See Also:



53
54
55
# File 'lib/librevox/commands.rb', line 53

def fsctl *args, &block
  command "fsctl", args.join(" "), &block
end

#hash(*args, &block) ⇒ Object

Access the hash table that comes with FreeSWITCH.

Examples:

socket.hash :insert, :realm, :key, "value"
socket.hash :select, :realm, :key
socket.hash :delete, :realm, :key


28
29
30
# File 'lib/librevox/commands.rb', line 28

def hash *args, &block
  command "hash", args.join("/"), &block
end

#hupall(cause = nil, &block) ⇒ Object



57
58
59
# File 'lib/librevox/commands.rb', line 57

def hupall cause=nil, &block
  command "hupall", cause, &block
end

#originate(url, args = {}, &block) ⇒ Object

Originate a new call.

Examples:

Minimum options

socket.originate 'sofia/user/coltrane', :extension => "1234"

With :dialplan and :context

See Also:



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/librevox/commands.rb', line 37

def originate url, args={}, &block
  extension = args.delete(:extension)
  dialplan  = args.delete(:dialplan)
  context   = args.delete(:context)

  vars = args.map {|k,v| "#{k}=#{v}"}.join(",")

  arg_string = "{#{vars}}" + 
    [url, extension, dialplan, context].compact.join(" ")
  command "originate", arg_string, &block
end

#status(&block) ⇒ Object



19
20
21
# File 'lib/librevox/commands.rb', line 19

def status &block
  command "status", &block
end

#uuid_bridge(uuid1, uuid2, &block) ⇒ Object

Bridge two call legs together. At least one leg must be anwered.

Examples:

socket.uuid_bridge "592567a2-1be4-11df-a036-19bfdab2092f", "58b39c3a-1be4-11df-a035-19bfdab2092f"

See Also:



73
74
75
# File 'lib/librevox/commands.rb', line 73

def uuid_bridge uuid1, uuid2, &block
  command "uuid_bridge", "#{uuid1} #{uuid2}", &block
end

#uuid_park(uuid, &block) ⇒ Object

Park call.

Examples:

socket.uuid_park "592567a2-1be4-11df-a036-19bfdab2092f"

See Also:



65
66
67
# File 'lib/librevox/commands.rb', line 65

def uuid_park uuid, &block
  command "uuid_park", uuid, &block
end