Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/librevox/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,33 @@ def uuid_park(uuid)
command "uuid_park", uuid
end

# Hang up a call, with an optional cause.
# @example
# socket.uuid_kill "592567a2-1be4-11df-a036-19bfdab2092f", "NO_ROUTE_DESTINATION"
# @see http://wiki.freeswitch.org/wiki/Mod_commands#uuid_kill
def uuid_kill(uuid, cause = nil)
command "uuid_kill", [uuid, cause].compact.join(" ")
end

# Schedule a hangup. `time` is seconds from now with a leading "+", or an
# epoch time.
# @example
# socket.sched_hangup "+3600", "592567a2-1be4-11df-a036-19bfdab2092f", "ALLOTTED_TIMEOUT"
# @see http://wiki.freeswitch.org/wiki/Mod_commands#sched_hangup
def sched_hangup(time, uuid, cause = nil)
command "sched_hangup", [time, uuid, cause].compact.join(" ")
end

# Delete a scheduled task by its id, or every task in a group. A call's
# scheduled tasks (sched_hangup, sched_transfer, …) are grouped by its uuid.
# FreeSWITCH replies "+OK Deleted: <count>".
# @example
# socket.sched_del "592567a2-1be4-11df-a036-19bfdab2092f"
# @see http://wiki.freeswitch.org/wiki/Mod_commands#sched_del
def sched_del(id)
command "sched_del", id
end

# Bridge two call legs together. At least one leg must be answered.
# @example
# socket.uuid_bridge "592567a2-1be4-11df-a036-19bfdab2092f", "58b39c3a-1be4-11df-a035-19bfdab2092f"
Expand Down
21 changes: 21 additions & 0 deletions test/unit/librevox/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,25 @@ def test_uuid_bridge
assert_equal "uuid_bridge", cmd[:name]
assert_equal "1234-abcd 9090-ffff", cmd[:args]
end

def test_uuid_kill
cmd = C.uuid_kill "1234-abcd"
assert_equal "uuid_kill", cmd[:name]
assert_equal "1234-abcd", cmd[:args]

cmd = C.uuid_kill "1234-abcd", "NO_ROUTE_DESTINATION"
assert_equal "1234-abcd NO_ROUTE_DESTINATION", cmd[:args]
end

def test_sched_hangup
cmd = C.sched_hangup "+3600", "1234-abcd", "ALLOTTED_TIMEOUT"
assert_equal "sched_hangup", cmd[:name]
assert_equal "+3600 1234-abcd ALLOTTED_TIMEOUT", cmd[:args]
end

def test_sched_del
cmd = C.sched_del "1234-abcd"
assert_equal "sched_del", cmd[:name]
assert_equal "1234-abcd", cmd[:args]
end
end