Learn how to create a Microsoft Lync Server 2013 SDK message filter MSPL script.

Writing a message filter script

A message filter is an Microsoft SIP Processing Language (MSPL) scripting application that traps SIP messages that are based on one or more criteria, and then either processes the messages or dispatches them to a managed code application for processing.

Tips for writing message filter scripts

  • Ensure that you always handle a request when you call a function like Fork by enclosing it in an if (!sipResponse) { ... }section. For response-specific functions like ProxyResponse , an if (!sipRequest) { ... }section is similarly appropriate. Remember, every time that a function attempts to process a message type it cannot handle, a critical MSPL error is raised against your application and recorded in the server event log. If ten of these errors occur, your application is disabled by Microsoft Lync Server 2013. Divide your filter into discrete sections for handling each class of message—response and request—and implement their processing separately.

  • Log is the only effective mechanism you have to debug your code logic. Although the ComipleSPL.exe (for a script-only SIP application) or ApplicationManifest.Compile method (for a managed SIP application) will catch syntactical errors, code logic errors must be debugged by using ApiLogger.exe (ApiLogger.exe is distributed with Lync Server 2013). Call Logif a message with a specific SIP method is identified, or when any meaningful action is taken when a message is processed.

  • When forking a message, BeginFork , Fork , and EndFork must be called in the implied order. Calling one out of order generates an error. Fork can be called as many times for as many messages as appropriate as long as BeginFork has not been closed with a subsequent call to EndFork . When EndFork is called, all of the messages previously specified with calls to Fork after the initial BeginFork , are forked. If you do not call EndFork , the forked messages are not sent, and an error is generated.

  • If your application is declared as script-only by using the scriptOnly element , compilation fails if you attempt to call the Dispatch function.

See also