-
-
Application Development
-
-
CCS Scripting Language
-
Overview
-
CCS scripting language provides to develop call service application running on NicIVR. It has several APIs for call connection and media processing and also it's possible to define various data types; process the statements, expressions; catch the signalling and custom events.
CCS is a simple and flexible scripting language thus provides developers to create call service in a very short time. Syntax and symantics of major programming languages such as C, Java Script or PHP can be found in the language.
A call service application can consist of only one script file or many file that process different call state individually and linked each other. Always starts from "main" function in the "main.ccs" script file. The Script compiler compiles all script files and generates an output. The output file is loaded within 1 minute and the new call flow is activated on runtime.
Scripting Features and Example Codes
Call flow consist of one or many files but starts only main.ccs text based file. Main script file includes "main" function, global variables which is accessable from any other script file and global functions.
Some of scripting features:
- All events start with "EVENT" keyword before event name and functions start with "FUNCTION" keyword before function name. Functions can also get parameters, return value.
- System events are called automatically at the corresponding signal time.
- Custom events can be implemented in a script file and called from every file using the file and event name. Exp. RunScript("QueryDestination.ccs", "UserEvent");
- for and while loops are used to create loop logic.
- Integer, string, bool and double data types are supported in script development. "if" block process the statements. There is no restriction to implement the local variables at the beginning of function block. (like C++)
Please take a look at state-of-art scripting language design
Talking with a RADIUS Server
Radius scripting functions provides to make AAA operations very easy. There is no need to remember the standart attribute types. If the VSA dictionary file is on the path, the VSA parameter types are authomatically loaded when the system starts to run.
A sample authorization request:
FUNCTION bool AuthorizeUser()
{
// Add the standart attributes to the authorization packet
AddRadiusAttr(1, g_strUser); // User
AddRadiusAttr(2, g_strPassword); // Password
AddRadiusAttr(4, _IVR_IP_); // Nas Ip Address
AddRadiusAttr(5, i2str(_SESSION_ID_)); // Nas Port
AddRadiusAttr(61, "0"); // Nas Port Type
AddRadiusAttr(31, _CALLING_NR_); // Calling Id
AddRadiusAttr(30, _CALLED_NR_); // Called Id
AddRadiusAttr(44, i2str(_SESSION_ID_)); // Acct Session Id
// Add VSAs to the authorization packet
AddRadiusVSAAttr(24, "h323-conf-id=" + g_strh323confid, 9);
// Send the packet to server
bool bRet = FALSE;
int iRet = SendRadiusRequest(1, APP_SERVER_RADIUS, 1812);
if (iRet == 0) { // ACCESS_ACCEPT
// Get the value for exp. in the VSA(103) returning parameter
string strReturnCode = GetRadiusVSAAttrValue(103);
if (str2i(strReturnCode) > 0) {
bRet = FALSE;
}
else {
// Get the other params in the logic
string strCreditTime = GetRadiusVSAAttrValue(102);
string strBillingModel = GetRadiusVSAAttrValue(109);
bRet = TRUE;
}
}
if (iRet == 1) { // ACCESS_REJECT
string strReturnCode = GetRadiusVSAAttrValue(103);
LOG("Radius reject");
}
if (iRet == 2) { // PACKET_SEND_PROBLEM
LOG("Radius send Technical problem");
}
ResetRadius();
return bRet;
}
A sample AccountingStart packet:
FUNCTION RadiusStartAccounting()
{
g_strSetupTime = GetTime();
LOG("Setup Time : " + g_strSetupTime);
// Add the standart attributes to the accounting packet
AddRadiusAttr(40, "1"); // Accounting Status Type(value=1 acc start)
AddRadiusAttr(6, "1"); // Service Type (value=1 Login)
AddRadiusAttr(61, "0"); // Nas Port Type
AddRadiusAttr(4, _IVR_IP_); // Nas Ip Address
AddRadiusAttr(5, i2str(_SESSION_ID_)); // Nas Port
AddRadiusAttr(41, "0"); // Acct Delay Time
AddRadiusAttr(44, i2str(_SESSION_ID_)); // Acct Session Id
AddRadiusAttr(1, g_strUser); // User
AddRadiusAttr(2, g_strPassword); // Password
AddRadiusAttr(31, _CALLING_NR_); // Calling Id
AddRadiusAttr(30, g_strDestRadius); // Called Id
// Add the VSAs to the accounting packet
AddRadiusVSAAttr(27, "h323-call-type=VoIP", 9);
AddRadiusVSAAttr(1, "subscriber=RegularLine", 9);
AddRadiusVSAAttr(25, "h323-setup-time=" + FormatTime(g_strSetupTime,
"%H:%M:%S.000 UTC %a %b %d %Y"), 9);
AddRadiusVSAAttr(24, "h323-conf-id=" + g_strh323confid, 9);
AddRadiusVSAAttr(26, "h323-call-origin=originate", 9);
AddRadiusVSAAttr(1, "calling-party-category=0", 9);
// Send the accounting packet to server
int nRet = SendRadiusRequest(4, APP_SERVER_RADIUS, 1813);
if (nRet == 0) {
LOG("RadiusStartAccounting successful");
}
if (nRet == 2) {
LOG("RadiusStartAccounting Radius send Technical problem");
}
ResetRadius();
}
Talking with an Application Running on HTTP Server
Sometimes to send/get information from/to a web page(asp/aspx,php,jsp etc.) is the easiest way to manage the main data. This is the most flexible method to access or manupilate information. HTTP interface loads the parameters, creates xml data and sends it to the page running on web server. Unlimited actions can take on the page. Finally a result is generated on an xml format and send back to system. Then the results are used in the running call flow.
A sample HTTP Request/Response process:
FUNCTION FindDuration()
{
AddXMLParam("Origination", _CALLING_NR_);
AddXMLParam("Destination", _CALLED_NR_);
AddXMLParam("SessionID", i2str(_SESSION_ID_));
// Send the parameters to web page running on 212.35.30.82
bool bRet = PostHttpXML("212.35.30.82", "/servLet.asp");
if (bRet != TRUE) {
LOG("PostHttpXML Failed. Error Description:" +
GetLastRuntimeErrorMessage());
}
// Call duration value is returned from server
string strDuration = GetXMLParamValue("MaxCallDuration");
// Assing it to a global variable...
g_nDuration = str2i(strDuration);
ResetXML();
}
Script Compiler
SCC.exe is the script compiler to make a binary file to be running on the system when a session is created. Intelligent compiler finds definition, type mismatch, wrong function and keyword usage errors and then reports the occurance of each error by file name and line number. Also explains the error reason.
FUNCTION QueryDestination()
{
string strMaxCallDuration;
g_strest = g_strDigits;
// g_strest is wrong. Should be g_strDest
LOG("Everything is ok. Starting the call to " + strDestination);
StartCall(_LEG_A_, g_strDest);
// Missing parameters.
// Sould be StartCall(_LEG_A_, _LEG_B_, g_strDest);
LOG("Calling " + g_strDigits);
RunScript("Ringing.ccs");
}
There are 2 basic errors in the function block: