IWMSEventNotificationPlugin.OnEvent (C#)
The server calls the OnEvent method when an event subscribed to by the plug-in occurs.
void IWMSEventNotificationPlugin.OnEvent(
ref WMS_EVENT pEvent,
IWMSContext pUserCtx,
IWMSContext pPresentationCtx,
IWMSCommandContext pCommandCtx
);
Arguments
[in] Reference to a WMS_EVENT structure containing the event. |
|
[in] IWMSContextIWMSContext Object (C#) containing the User Context. |
|
[in] IWMSContext object containing the Presentation Context. |
|
[in] IWMSCommandContextIWMSCommandContext Object (C#) 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 (C#) 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 void OnEvent(
ref WMS_EVENT pEvent,
IWMSContext pUserCtx,
IWMSContext pPresentationCtx,
IWMSCommandContext pCommandCtx)
{
IWMSContext CmdRequest;
int iSubEvent;
try
{
pCommandCtx.GetCommandRequest(out CmdRequest);
CmdRequest.GetLongValue(WMSDefines.WMS_COMMAND_CONTEXT_EVENT,
WMSDefines.WMS_COMMAND_CONTEXT_EVENT_ID,
out iSubEvent, 0);
switch( pEvent.Type )
{
case WMS_EVENT_TYPE.WMS_EVENT_PLUGIN:
// TODO: Handle plug-in events.
break;
case WMS_EVENT_TYPE.WMS_EVENT_PUBLISHING_POINT:
// TODO: Handle publishing point events.
break;
case WMS_EVENT_TYPE.WMS_EVENT_SERVER:
// TODO: Handle server events.
break;
case WMS_EVENT_TYPE.WMS_EVENT_LIMIT_CHANGE:
int iOldValue;
int iNewValue;
CmdRequest.GetLongValue(
WMSDefines.WMS_COMMAND_CONTEXT_LIMIT_OLD_VALUE,
WMSDefines.WMS_COMMAND_CONTEXT_LIMIT_OLD_VALUE_ID,
out iOldValue, 0);
CmdRequest.GetLongValue(
WMSDefines.WMS_COMMAND_CONTEXT_LIMIT_NEW_VALUE,
WMSDefines.WMS_COMMAND_CONTEXT_LIMIT_NEW_VALUE_ID,
out iNewValue, 0);
if( iSubEvent == (int)WMS_LIMIT_CHANGE_EVENT_TYPE.WMS_EVENT_LIMIT_CHANGE_CONNECTED_PLAYERS )
// TODO: Handle connected players limit change event.
else if( iSubEvent == (int)WMS_LIMIT_CHANGE_EVENT_TYPE.WMS_EVENT_LIMIT_CHANGE_CONNECTION_RATE )
// TODO: Handle connection rate limit change event.
else
// TODO: Handle other limit change events.
break;
}
}
catch( Exception e )
{
// TODO: Handle exceptions.
}
}
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.