IUccSession.RemoveParticipant 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.

Removes an existing participant from the session participant collection.

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

Syntax

'Declaration
Sub RemoveParticipant ( _
    pParticipant As IUccSessionParticipant, _
    pOperationContext As UccOperationContext _
)
void RemoveParticipant (
    IUccSessionParticipant pParticipant,
    UccOperationContext pOperationContext
)
void RemoveParticipant (
    IUccSessionParticipant^ pParticipant, 
    UccOperationContext^ pOperationContext
)
void RemoveParticipant (
    IUccSessionParticipant pParticipant, 
    UccOperationContext pOperationContext
)
function RemoveParticipant (
    pParticipant : IUccSessionParticipant, 
    pOperationContext : UccOperationContext
)

Parameters

  • pParticipant
    A value of the IUccSessionParticipant* (IUccSessionParticipant, for a .NET application) type. This specifies the to-be-removed participant.
  • pOperationContext
    A value of the IUccOperationContext* (UccOperationContext, for a .NET application) type. The default value is NULL. This specifies the optional operation context. The NULL value is acceptable.

Remarks

In a peer-to-peer session with two users, calling RemoveParticipant removes the remote user from the local instance of the session. Removing a remote user from the local session does not affect the remote user's session. The remote user is not notified of the removal, This method effectively blocks communication from the removed user. In an instant messaging session, the local user may still send text to the removed user. The local user no longer receives events originating with the removed user.

If the session is a transmission-free session such as a conference session, all session participant endpoints receive OnParticipantRemovedto notify each local client of the removed session participant.

Win32 COM/C++ Syntax

HRESULT RemoveParticipant
(
   IUccSessionParticipant* pParticipant,
   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 is drawn from an application class that wraps an instance of IUccSession (_session). The example accepts a string Uri parameter to match against each session participant in the Participants collection of the current session. When a match is found, the matching participant is removed from the session. An operation context is supplied with the remove operation. The participant to be removed is advised that the class is not longer interested in events raised by the participant before it is de-referenced. This last step prevents the client application from leaking a small amount of memory.

/// <summary>
/// removes a participant represented by the string Uri passed
/// </summary>
/// <param name="sipUri">SIP address of participant to be removed</param>
/// <param name="operationContext">operation context to supply to remove operation</param>
public void RemoveParticipant(string sipUri, UccOperationContext operationContext)
{
    if (_session == null)
        return;

    if (_session.Participants.Count <= 0)
        return;

    foreach (IUccSessionParticipant p in _session.Participants)
    {
        if (p.Uri.Value == sipUri)
        {
            UCC_Unadvise<_IUccInstantMessagingSessionParticipantEvents>(
                p, 
                this);
            _session.RemoveParticipant(p, operationContext);
        }
    }

}

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#