次の方法で共有


IWMSEventNotificationPlugin.OnEvent (Visual Basic .NET)

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

IWMSEventNotificationPlugin.OnEvent(  ByRef pEvent As WMS_EVENT,
  pUserCtx As IWMSContext,
  pPresentationCtx As IWMSContext,
  pCommandCtx As IWMSCommandContext
)

Arguments

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

[in] IWMSContextIWMSContext Object (Visual Basic .NET) containing the User Context.

[in] IWMSContext object containing the Presentation Context.

[in] IWMSCommandContextIWMSCommandContext Object (Visual Basic .NET) containing the Command Context.

Return Value

This method does not return a value. To report an error, the plug-in can throw a COMException object to the server. If the plug-in uses the IWMSEventLogIWMSEventLog Object (Visual Basic .NET) to log error information, it is recommended that it throw NS_E_PLUGIN_ERROR_REPORTED (0xC00D157D). 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 object to send custom error information to the Windows Event Viewer, throwing NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about plug-in error information, see Identifying Plug-in Errors.

Example

Public Sub OnEvent( _
    ByRef pEvent As WMS_EVENT, _
    ByVal pUserCtx As IWMSContext, _
    ByVal pPresentationCtx As IWMSContext, _
    ByVal pCommandCtx As IWMSCommandContext) _
    Implements IWMSEventNotificationPlugin.OnEvent

    Dim CmdRequest As IWMSContext
    Dim iSubEvent As Integer

    Try
        pCommandCtx.GetCommandRequest(CmdRequest)
        CmdRequest.GetLongValue(WMSDefines.WMS_COMMAND_CONTEXT_EVENT, _
                                WMSDefines.WMS_COMMAND_CONTEXT_EVENT_ID, _
                                iSubEvent, 0)

        Select Case pEvent.Type
            Case WMS_EVENT_TYPE.WMS_EVENT_PLUGIN
                ' TODO: Handle plug-in events.
            Case WMS_EVENT_TYPE.WMS_EVENT_PUBLISHING_POINT
                ' TODO: Handle publishing point events.
            Case WMS_EVENT_TYPE.WMS_EVENT_SERVER
                ' TODO: Handle server events.
            Case WMS_EVENT_TYPE.WMS_EVENT_LIMIT_CHANGE
                Dim iOldValue As Integer
                Dim iNewValue As Integer

                CmdRequest.GetLongValue( _
                      WMSDefines.WMS_COMMAND_CONTEXT_LIMIT_OLD_VALUE, _
                      WMSDefines.WMS_COMMAND_CONTEXT_LIMIT_OLD_VALUE_ID, _
                      iOldValue, 0)
                CmdRequest.GetLongValue( _
                      WMSDefines.WMS_COMMAND_CONTEXT_LIMIT_NEW_VALUE, _
                      WMSDefines.WMS_COMMAND_CONTEXT_LIMIT_NEW_VALUE_ID, _
                      iNewValue, 0)
                If iSubEvent = WMS_LIMIT_CHANGE_EVENT_TYPE.WMS_EVENT_LIMIT_CHANGE_CONNECTED_PLAYERS Then
                    ' TODO: Handle connected players limit change event.
                ElseIf iSubEvent = WMS_LIMIT_CHANGE_EVENT_TYPE.WMS_EVENT_LIMIT_CHANGE_CONNECTION_RATE Then
                    ' TODO: Handle connection rate limit change event.
                Else
                    ' TODO: Handle other limit change events.
                End If
        End Select

    Catch e As Exception
        ' TODO: Handle exceptions.
    End Try
End Sub

Requirements

Reference: Add a reference to Microsoft.WindowsMediaServices.

Namespace: Microsoft.WindowsMediaServices.Interop.

Assembly: Microsoft.WindowsMediaServices.dll.

Library: WMSServerTypeLib.dll.

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

See Also

Concepts

IWMSEventNotificationPlugin Object (Visual Basic .NET)