IUccSession.Terminate Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Terminates a session.

Namespace: Microsoft.Office.Interop.UccApi
Assembly: Microsoft.Office.Interop.UccApi (in microsoft.office.interop.uccapi.dll)

Syntax

'Declaration
Sub Terminate ( _
    enTerminateReason As UCC_REJECT_OR_TERMINATE_REASON, _
    pOperationContext As UccOperationContext _
)
void Terminate (
    UCC_REJECT_OR_TERMINATE_REASON enTerminateReason,
    UccOperationContext pOperationContext
)
void Terminate (
    UCC_REJECT_OR_TERMINATE_REASON enTerminateReason, 
    UccOperationContext^ pOperationContext
)
void Terminate (
    UCC_REJECT_OR_TERMINATE_REASON enTerminateReason, 
    UccOperationContext pOperationContext
)
function Terminate (
    enTerminateReason : UCC_REJECT_OR_TERMINATE_REASON, 
    pOperationContext : UccOperationContext
)

Parameters

  • pOperationContext
    A value of the IUccOperationContext* (UccOperationContext, for a .NET application) type. The default value is NULL. This specifies the application-specified properties associated with this asynchronous request.

Remarks

When Terminate is called by either user in a two user peer-to-peer session, both users receive OnTerminate. The session is terminated for both users. If more than two users are participating in a single session, only the local user's session is terminated. The session is active as long as at least two users participate.

Note

Do not use the enumeration, UCCROTR_NOT_SPECIFIED in the enTerminateReason parameter. The remote session participant clients are not properly notified of the local user session termination unless a termination reason is specified.

Win32 COM/C++ Syntax

HRESULT Terminate
(
   UCC_REJECT_OR_TERMINATE_REASON enTerminateReason,
   IUccOperationContext* pOperationContext
);

Note

In a Win32 application, the return value of a method or property is always an HRESULT value indicating the status of the call to the interface member. Any result of the operation is returned as a parameter marked with the [out, retval] attribute. In contrast, in a .NET application the HRESULT value indicating an error condition is returned as a COM exception and the [out, retval] parameter becomes the return value. For the UCC API-defined HRESULT values, see Trace and Handle Errors in Unified Communications Client API.

Example

The following example terminates a session and unadvises for session participant related events. The example application advised for both _IUccSessionParticipantEvents and _IUccInstantMessagingSessionParticipantEvents, therefore the client should un-advise for the same events.

/// <summary>
/// terminates the IM session wrapped by this class
/// Each session participant is unadvised for participant events
/// after being removed from the session. Finally, the session itself is
/// terminated
/// </summary>
/// <param name="sender">the UI button initiating the termination</param>
/// <param name="e">event data</param>
private void b_Terminate_Click(object sender, EventArgs e)
{
    if (this.thisSession != null)
    {
        IUccCollection partCollection = thisSession.Participants;
        int i = 0;
        int count = partCollection.Count;
        foreach (object o in partCollection)
        {
            IUccSessionParticipant sp = o as IUccSessionParticipant;
            this.thisSession.RemoveParticipant(sp,null);
            UCC_Unadvise<_IUccInstantMessagingSessionParticipantEvents>(
                sp, 
                this);
            UCC_Unadvise<_IUccSessionParticipantEvents>(
                sp, 
                this); 
            i++;
        }
        this.thisSession.Terminate(
        UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE_EVERYWHERE, 
        null);
    }
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2000 with Service Pack 4, Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

IUccSession Interface
IUccSession Members
Microsoft.Office.Interop.UccApi Namespace

Other Resources

Code Listing: Basic Event Registration and Other Helper Methods in C#