Skip to content

Instantly share code, notes, and snippets.

@pdeschen
Created December 1, 2011 22:57
Show Gist options
  • Save pdeschen/1420520 to your computer and use it in GitHub Desktop.
Save pdeschen/1420520 to your computer and use it in GitHub Desktop.
Multi Providers Dialplan Context
context multi-provider {
_X. => {
if (${GLOBAL(provider_1_limit)} > ${GLOBAL(provider_1_count)}) {
Set(PROVIDER_CONTEXT=provider_1);
}
else if (${GLOBAL(provider_2_limit)} > ${GLOBAL(provider_2_count)}) {
Set(PROVIDER_CONTEXT=provider_2);
}
else {
Congestion();
}
GLOBAL(${PROVIDER_CONTEXT}_count)=GLOBAL(${PROVIDER_CONTEXT}_count)+1;
Dial(SIP/${PROVIDER_CONTEXT}/${EXTEN});
Congestion();
};
h => {
// we could be handling from congestion
if (${GLOBAL(${PROVIDER_CONTEXT}_count)} > 0) {
GLOBAL(${PROVIDER_CONTEXT}_count)=GLOBAL(${PROVIDER_CONTEXT}_count)-1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment