Altering release cause
From Yate Documentation
(Difference between revisions)
(Created page with "Yate provides a default mapping from the call release cause of the call leg that initiated the release. You may want to alter the release cause or to enforce specific mapping...") |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 12: | Line 12: | ||
The following [[Javascript]] is an example of altering the release cause. The script can be placed in the share/scripts directory and be configured in javascript.conf | The following [[Javascript]] is an example of altering the release cause. The script can be placed in the share/scripts directory and be configured in javascript.conf | ||
+ | |||
+ | In javascript.conf | ||
+ | |||
+ | [scripts] | ||
alter_cause=alter_release_cause.js | alter_cause=alter_release_cause.js | ||
Line 43: | Line 47: | ||
} | } | ||
break; | break; | ||
− | case /^h323/: | + | case /^h323\//: |
// Cause propagated to H.323 | // Cause propagated to H.323 | ||
switch (msg.reason) { | switch (msg.reason) { | ||
Line 60: | Line 64: | ||
Message.install(onDisconnected,"chan.disconnected",80); | Message.install(onDisconnected,"chan.disconnected",80); | ||
+ | |||
+ | [[Category:Javascript]] [[Category:Change reason]] |
Latest revision as of 18:09, 31 October 2013
Yate provides a default mapping from the call release cause of the call leg that initiated the release.
You may want to alter the release cause or to enforce specific mappings per protocol.
[edit] Concept
When a call leg is released a cause code is received over the protocol or is generated locally in case of an error.
The peer of the hung up call leg gets disconnected. At this stage it sends a chan.disconnected message that can be used to prevent the call release or to alter the propagated release cause.
[edit] Example
The following Javascript is an example of altering the release cause. The script can be placed in the share/scripts directory and be configured in javascript.conf
In javascript.conf
[scripts] alter_cause=alter_release_cause.js
Content of a very simple script:
function onDisconnected(msg) { if (msg.reason == "congestion") msg.reason = "busy"; return false; } Message.install(onDisconnected,"chan.disconnected",80);
A more complex script:
function onDisconnected(msg) { var newreason = false; switch (msg.id) { case /^sip\//: // Cause propagated to SIP switch (msg.lastpeerid) { case /^sip\//: // SIP to SIP switch (msg.reason) { case "noroute": newreason = "congestion"; break; case "rejected": newreason = "forbidden"; break; } break; } break; case /^h323\//: // Cause propagated to H.323 switch (msg.reason) { case "congestion": newreason = "busy"; break; } break; } if (newreason) { Engine.debug(Engine.DebugInfo,"Changing end reason '" + msg.reason + "' to '" + newreason + "'"); msg.reason = newreason; } return false; } Message.install(onDisconnected,"chan.disconnected",80);