Learn how to use the Transaction class to create and manage SIP transactions in a Microsoft Lync Server 2013 deployment.

Creating and managing SIP transactions

The Microsoft.Rtc.Sip namespace defines a base type, Transaction , that represents the basic properties that are used in a SIP transaction. This includes the request that started the transaction, responses that are handled by the transaction, and events that are used to catch transaction status changes (such as time-out events or cancellations).

The following types are derived from the Transactionclass:

The ServerTransactioninstance is obtained by referencing the ServerTransaction property on the RequestReceivedEventArgs instance, when a RequestReceivedEventArgsobject is dispatched to the designated method. The request it was created to service can be obtained by using one of the following properties:

  • The RequestReceivedEventArgs; Request property

  • Request () () () ()

Client transactions must be created programmatically by calling CreateBranch () () () () on the ServerTransaction . The UAC case, where a client transaction originates a request and does not have a parent server transaction, is not supported.

To fork a message, ServerTransaction.CreateBranchcan be called as many times as forks are needed. To send a request to each fork, call SendRequest(Request) on each branch.

Responses to serviced requests are obtained by registering a handler for the ResponseReceived event. When this event is raised, any response that is received by Lync Server 2013 that matches the originating request is sent as a ResponseReceivedEventArgs object to the method registered by using the ResponseReceivedEventHandler delegate.

Responses can also be raised by using dispatches from the message filter script when it is set to filter responses. In this case, the response will be out-of-context because there is no ClientTransactionobject on the server that originated the request. In this case, the new ClientTransactionobject is obtained by referencing the ClientTransaction property on the ResponseReceivedEventArgs instance. The server transaction that forwards the response is obtained by referencing the ServerTransaction property on this ClientTransactioninstance, which contains the new ServerTransactioninstance to handle it.

If a CANCELmethod is received for a transaction, the Canceled event is raised. When the transaction is closed, Terminated is raised. If a transaction times out, TimedOut is raised.

See also