SIP Forking Proxy Application
A forking proxy forwards a SIP request to multiple SIP addresses and returns the responses to the sender. Basic forking proxies are best handled in the MSPL message filter. This description shows the object model for the forking behavior.
SIP Forking Proxy Behavior
The following diagram illustrates the basic flow of a forking proxy.
When a message is dispatched to the application by the MSPL script, a RequestReceivedEventArgs object is returned to the method inside the application designated by the Dispatch call. Attached to this object is a new ServerTransaction object, which contains the Request object as the ServerTransaction.Request property.
To fork the Request, clone ServerTransaction.Request for each recipient. First, ensure that the ServerTransaction.EnableForking property is set to true. If this property has been set to false (the default is true), ArgumentException will be thrown when you call ServerTransaction.CreateBranch a second time.
For each proxied request, call ServerTransaction.CreateBranch and then immediately call ClientTransaction.SendRequest, passing in the cloned Request.
Responses are handled asynchronously through the ResponseReceivedEventHandler delegate. The ClientTransaction.ResponseReceived event is triggered when a response for a sent Request is received, and the corresponding Response object is returned as the ResponseReceivedEventArgs.Response property.
To proxy the response, call ServerTransaction.SendResponse, passing in ResponseReceivedEventArgs.Response.
When a final response is passed to the server transaction, the object space containing the ServerTransaction and its branches will be automatically disposed of by the server agent, unless the ServerTransaction.Close() method on ServerTransaction has been overridden.