diff --git a/lib/librevox/commands.rb b/lib/librevox/commands.rb index 5788b76..40b7fff 100644 --- a/lib/librevox/commands.rb +++ b/lib/librevox/commands.rb @@ -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: ". + # @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" diff --git a/test/unit/librevox/commands_test.rb b/test/unit/librevox/commands_test.rb index 219bdc6..f7e65d0 100644 --- a/test/unit/librevox/commands_test.rb +++ b/test/unit/librevox/commands_test.rb @@ -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