MSPL Built-in Variables
MSPL Built-in Variables
MSPL defines eight built-in variables for use with SIP message processing:
Message sipMessage;
Request sipRequest;
Response sipResponse;
SourceInfo RequestSource (This is introduced in Microsoft Lync Server 2010.)
RegistrarEndpoint dbEndpoint;
string FQDN;
string ServerPool;
ServerRole Role;
TargetInfo RequestTarget;
Message (MSPL) sipMessage;
The sipMessage variable contains the current SIP message passed from Lync Server 2010 to the application.
Request sipRequest;
The sipRequest variable contains the current SIP request message passed from Lync Server 2010 to the application.
Response sipResponse;
The sipResponse variable contains the current SIP response message passed from Lync Server 2010 to the application.
SourceInfo RequestSource
The RequestSource variable contains the source of the current SIP request message passed from Lync Server 2010 to the application. This variable is introduced in Lync Server 2010.
Scripts test for the message type (request or response) by first determining if the corresponding built-in variable evaluates to true or false. If it evaluates to true, the message is the one tested for. If false, it is not.
For example, to test if the current message is a request:
if (sipRequest) {
...
// Process the request here.
...
}
Then, to test if the message is a response:
if (sipResponse) {
...
// Process the request here.
...
}
This test should always be performed before any expressions involving fields on the request/response are performed. For example, if you attempt to access the StatusClass field on the sipResponse variable before determining that the message is, in fact, a response, it will return false instead of the expected status code string when a request or server notification is encountered instead of a response. This leads to logical errors when code like
sipResponse.StatusClass != StatusClass._2xx;
is encountered when a message type determination has not been made. The previous code always evaluates to true for anything but a response; in this case, checking the message type is important to ensure proper filtering.
You can store the body of a message in the Content field. As a result, the following expressions are valid in MSPL:
sipMessage.Content = "this is the body of a message";
sipRequest.Content = "this is the body of a request";
sipResponse.Content = "this is the body of a response";
RegistrarEndpoint dbEndpoint;
The dbEndpoint variable contains a network endpoint as stored in the Lync Server 2010 registrar database. This variable is valid only within the scope of a foreach loop that iterates over the collection returned by a QueryEndpoints function call.
For example:
foreach (dbEndpoint in QueryEndpoints("user@contoso.org")) {
...
}
string FQDN;
The FQDN variable contains the fully qualified DNS name of the local server.
string ServerPool;
The ServerPool variable specifies the name of the pool of the server on which the application is running.
Note
All references to built-in variables are read-only.
ServerRole Role;
The Role variable contains the role of the server where the SPL is executing.
TargetInfo RequestTarget;
The RequestTarget variable contains details about the target of the request. This is valid only if the script is executing because of a request (as opposed to a response).