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
-
#command(name, args = "") ⇒ Object
Executes a generic API command, optionally taking arguments as string.
-
#fsctl(*args, &block) ⇒ Object
FreeSWITCH control messages.
-
#hash(*args, &block) ⇒ Object
Access the hash table that comes with FreeSWITCH.
- #hupall(cause = nil, &block) ⇒ Object
-
#originate(url, args = {}, &block) ⇒ Object
Originate a new call.
- #status(&block) ⇒ Object
-
#uuid_bridge(uuid1, uuid2, &block) ⇒ Object
Bridge two call legs together.
-
#uuid_park(uuid, &block) ⇒ Object
Park call.
Instance Method Details
#command(name, args = "") ⇒ Object
Executes a generic API command, optionally taking arguments as string.
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.
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.
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.
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.
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.
65 66 67 |
# File 'lib/librevox/commands.rb', line 65 def uuid_park uuid, &block command "uuid_park", uuid, &block end |