IWMSEventNotificationPlugin::OnEvent

banner art

Previous Next

IWMSEventNotificationPlugin::OnEvent

The server calls the OnEvent method when an event subscribed to by the plug-in occurs.

Syntax

  HRESULT OnEvent(
  WMS_EVENT*  pEvent,
  IWMSContext*  pUserCtx,
  IWMSContext*  pPresentationCtx,
  IWMSCommandContext*  pCommandCtx
);

Parameters

pEvent

[in] Pointer to a WMS_EVENT structure containing the event.

pUserCtx

[in] Pointer to an IWMSContext interface containing the user context.

pPresentationCtx

[in] Pointer to an IWMSContext interface containing the presentation context.

pCommandCtx

[in] Pointer to an IWMSCommandContext interface containing the command context.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code. If the plug-in uses the IWMSEventLog interface to log error information directly to the Windows Event Viewer, it is recommended that it return NS_E_PLUGIN_ERROR_REPORTED. Typically, the server attempts to make plug-in error information available to the server object model, the Windows Event Viewer, and the troubleshooting list in the details pane of the Windows Media Services MMC. However, if the plug-in uses the IWMSEventLog interface to send custom error information to the Windows Event Viewer, returning NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about retrieving plug-in error information, see Identifying Plug-in Errors.

Example Code

The following example illustrates a possible implementation of the OnEvent method for a logging plug-in.

STDMETHODIMP CWMSLoggingPlugin::OnEvent( WMS_EVENT * pEvent, 
                                         IWMSContext * pUserCtx,
                                         IWMSContext * pPresentationCtx,
                                         IWMSCommandContext * pCommandCtx )
{
    HRESULT         hr = S_OK;
    IWMSContext    *pCtx = NULL;

    // Process a requested name change for the publishing point.
    if( WMS_EVENT_PUBLISHING_POINT == pEvent->Type )
    {
        LONG    lSubEvent = -1;
        IWMSContext * pCtx = NULL;

        // Use the command context to retrieve a command request context.
        hr = pCommandCtx->GetCommandRequest( &pCtx );

        // Retrieve the request from the request context.
        hr = pCtx->GetLongValue( WMS_COMMAND_CONTEXT_EVENT,
                                 WMS_COMMAND_CONTEXT_EVENT_ID, 
                                 &lSubEvent, 
                                 0 );
        // If the client did not request a publishing point
        // name change, then return.
        if( FAILED( hr ) || 
              ( WMS_EVENT_PUBLISHING_POINT_NAME_CHANGE != lSubEvent ) )
        {
            hr = pCtx->Release();
            return( S_OK );
        }

        // Process the requested name change. The
        // ProcessPubPtNameChange() function is user-defined.
        hr = ProcessPubPtNameChange();

        hr = pCtx->Release();

        return( hr );
    }
    
    // TODO: Process remaining cases.
}

Requirements

Header: event.h.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.

See Also

Previous Next