For the complete documentation index, see llms.txt. This page is also available as Markdown.

route order Tutorial

route_order tutorial

'route_order' is a method implemented in the base_routing and is use to order routes. This tutorial will explain how to use the parameter for the 'route_order' method.

route_order examples


Things to know about these examples:

  • The :show_route_order method print in the output window the order of the naps.

  • A new field called 'priority' needs to be add to the routes.

  • This script will not find any route match, therefore dropping the call.

route_order setup

Routes to order:

Calling      Called      NAP      Remapped NAP       Priority
5550000     2220000     sip_p1     isdn              4
5550000     1110000     sip_p3     sip               3
5550000     3330000     sip_p2     isdn_1            2

Nap list:

Name
sip_p1
sip_p3
sip_p2

The call and naps input in the test script window:

:route_field_name parameter


:route_field_name script example

Here how it can be order using the ':route_field_name' argument. The example script will order the routes by priority.

  1. puts "key = #{key}, value = #{value}" end

    end puts "Nap name:#{@local_name}, priority:#{@local_priority}"

    return true end

    end

    @@routing = SimpleOrdering.new

    def init_routes( routes ) @@routing.init routes end

    def route( call, nap_list ) puts "This script should put all the route priority order starting with the lowest." @@routing.route call, nap_list end

:route_field_name script output

This script will not find any route match, therefore dropping the call, but it will print in the output the route ordered according to their priority. The output should look like this (if tried in the test script window).

:method parameter


:method script example

Here how it can be order using the ':method' argument. The example script will order the routes alphabetically by nap. The example script will order the routes alphabetically by nap just like the 'proc' example.

  1. puts "key = #{key}, value = #{value}" end

    end puts "Nap name:#{@local_name}, priority:#{@local_priority}"

    return false end

    end

    @@routing = SimpleMethodOrdering .new

    def init_routes( routes ) @@routing.init routes end

    def route( call, nap_list ) puts "This script should put all the route priority order starting with the lowest." @@routing.route call, nap_list end

:method script output

This script will not find any route match, therefore dropping the call, but it will print in the output the route ordered alphabetically by nap. The output should look like this (if tried in the test script window).

:proc parameter


:proc script example

Here how it can be order using the ':proc' argument. The example script will order the routes alphabetically by nap just like the 'method' example

  1. puts "key = #{key}, value = #{value}" end

    end puts "Nap name:#{@local_name}, priority:#{@local_priority}"

    return false end

    end

    @@routing = SimpleProcOrdering .new

    def init_routes( routes ) @@routing.init routes end

    def route( call, nap_list ) puts "This script should put all the route priority order starting with the lowest." @@routing.route call, nap_list end

:proc script output

This script will not find any route match, therefore dropping the call, but it will print in the output the route ordered alphabetically by nap. The output should look like this (if tried in the test script window).


Back to Routing Script Tutorial.

Last updated

Was this helpful?