36 • Scripting
[
S N O M
4 S P
R O X Y
/ R
E G I S T R A R
M
A N U A L
]
snom technology AG • 37
[
S N O M
4 S P
R O X Y
/ R
E G I S T R A R
M
A N U A L
]
The comparisons for conditions is done case-insensitive, so that
“TRUE” also leads to execution of a body.
Note: In contrast to C, the body must be enclosed in brackets (“{“
and “}”), even if you have only one statement inside of the brackets.
Example:
if ($a == “17”) {
log(“Found a\n”);
}
else if ($b == “17”) {
log(“Found b\n”);
}
else if ($c == “17”) {
log(“Found c\n”);
}
else {
log(“Not found\n”);
}
foreach
The proxy does not support looping. This was done to avoid
endless loops. Endless loops are catastrophic for the proxy as it sill stop
service in such a case.
The alternative of looping is going through lists. Lists always have
a defined length and there is no danger that the proxy will end up in an
endless loop.
The foreach command has the following syntax:
foreach(variable, list) { body }
The proxy will assign every element of the list to the provided
variable and execute the body. The scope of the variable of the current
context, that means the value of the variable after the foreach statement
will be the value of the last list element (if there was at least one
list element) or the variable will be unchanged (if there was no list
element).
The list is an expression that is evaluated before the execution of
the foreach statement starts. The result of the execution is interpreted as
string which contains the list elements separated by space.
Example:
6.
Summary of Contents for 4S Media Server
Page 1: ...Administrator s Manual snom 4S SIP Proxy Registrar Version 2 30 ...
Page 14: ...14 VoIP Protocol S N O M 4 S P R O X Y R E G I S T R A R M A N U A L 1 ...
Page 84: ...84 Routing S N O M 4 S P R O X Y R E G I S T R A R M A N U A L 10 ...
Page 98: ...98 Maintenance S N O M 4 S P R O X Y R E G I S T R A R M A N U A L 13 ...