ClientTransaction

ClientTransaction

The ClientTransaction class defines a SIP client transaction object located on a SIP proxy.

A ClientTransaction object is created by calling ServerTransaction.CreateBranch on a ServerTransaction object. For forking proxy behaviors, ServerTransaction.CreateBranch can be called multiple times; however, a ClientTransaction object itself can service only one request. To send the request, call ClientTransaction.SendRequest.

To handle the responses for the request sent by a specific client transaction, you must register for the ClientTransaction.ResponseReceived event. This event will return a ResponseReceivedEventArgs object whenever it is raised, and contains the response as a Response Sip Class object.

Currently, the UAC client transaction case is not supported, where the server originates a client transaction. Only proxy behaviors are available for this class.

The ClientTransaction class is derived from the Transaction Sip Class class.

Public Methods

The ClientTransaction class has the following public methods.

Method

Description

Transaction.Cancel

Inherited from Transaction. Cancels the transaction and raises the Transaction.Canceled event.

Transaction.Dispose ()

Inherited from Transaction. Releases all resources used by this object and destroys it.

Equals(Object)

Inherited from System.Object. Determines whether the specified System.Object is equal to the current System.Object.

GetHashCode()

Inherited from System.Object. Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.

GetType()

Inherited from System.Object. Gets the System.Type of the current instance.

ClientTransaction.SendRequest

Sends a SIP request to a server transaction on a proxy or UAS.

ToString()

Inherited from System.Object. Returns a System.String that represents the current System.Object.

Public Properties

The ClientTransaction class has the following public properties.

Property

Description

Transaction.OriginationTime

Data type: DateTimeAccess type: Read-only

Inherited from Transaction. Contains the date and time the transaction originated.

Request Properties

Data type: RequestAccess type: Read-only

Inherited from Transaction. Contains the Request object that initiated the transaction.

Responses

Data type: ResponseCollectionAccess type: Read-only

Inherited from Transaction. Contains a collection of all Response objects associated with the transaction.

ServerTransaction Properties

Data type: ServerTransactionAccess type: Read-only

Contains the root ServerTransaction object for which this client transaction is a branch.

Transaction.SyncRoot

Data type: ObjectAccess type: Read-only

Inherited from Transaction. Contains an object used for synchronizing access to a group of objects related to a server or client transaction.

Public Events

The ClientTransaction class has the following public events.

Event

Description

Transaction.Canceled

Inherited from Transaction. Occurs when the transaction is canceled.

ClientTransaction.ResponseReceived

Occurs when a response message for the request sent by the ClientTransaction object has been received.

Transaction.Terminated

Inherited from Transaction. Occurs when the transaction is terminated.

Transaction.TimedOut

Inherited from Transaction. Occurs when the transaction times out.

Protected Methods

The ClientTransaction class has the following protected methods.

Method

Description

Transaction.CheckDisposed

Inherited from Transaction. Throws ObjectDisposedException if the transaction is in the disposed state.

Transaction.Close

Inherited from Transaction. Releases all resources associated with the transaction.

ServerAgent.Dispose ()

Inherited from Transaction. Destroys this transaction and releases all unmanaged resources as well as optionally releasing all managed ones.

Transaction.Finalize

Inherited from Transaction. Provides a finalizer for this instance of the Transaction class.

Transaction.OnCanceled

Inherited from Transaction. Raises the Transaction.Canceled event.

ClientTransaction.OnResponseReceived

Raises the ClientTransaction.ResponseReceived event.

Transaction.OnTerminated

Inherited from Transaction. Raises the Transaction.Terminated event.

Transaction.OnTimedOut

Inherited from Transaction. Raises the Transaction.TimedOut event.

Remarks

For specific information on the nature of client transactions, the UAC, inbound and outbound proxies, and server transactions, see Section 17 of RFC 3261 (SIP: Session Initiation Protocol).

Example Code

The following code example logs the time a request is passed to the "OnRequest" dispatch handler, and then forwards the request by creating a branch on the server transaction passed to the handler. Requests are dispatched to this method from the MSPL script in the application manifest using the Dispatch MSPL function.

public void OnRequest(object sender, RequestReceivedEventArgs e)
{

Console.WriteLine("Enter OnRequest:" + System.DateTime.Now.ToLongTimeString());

ClientTransaction branch = e.ServerTransaction.CreateBranch();
branch.SendRequest(e.Request);

}

Requirements

Redistributable: Requires Microsoft Lync Server 2010

Namespace: Microsoft.Rtc.Sip

Assembly: ServerAgent (in ServerAgent.dll)

See Also

Concepts

ServerTransaction

ServerTransaction.CreateBranch

Transaction Sip Class