Share via


Event Notification Callback Procedures

The WMS Active Script Event Handler plug-in responds to event notices raised by the server by calling the appropriate callback in a script file that you create. Your script can implement the following event notification callback procedures.

Function prototype

Description

OnWMSEBeginUserSession (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a new user session begins.

OnWMSECache (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a local cache event, such as a cache hit or miss, occurs.

OnWMSEClose (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when it closes a client connection. This procedure is called before the OnWMSEDisconnect procedure.

OnWMSEConnect (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client attempts to connect to it. The first parameter will indicate whether the attempt was successful. This procedure cannot be used for a plug-in on a publishing point.

OnWMSECreateDistributionDataPath (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when it creates a data path for a push distribution.

OnWMSEDescribe (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client requests the description of a presentation.

OnWMSEDestroyDistributionDataPath (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when the server removes a data path that was created for a push distribution.

OnWMSEDisconnect (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure after a client is disconnected.

OnWMSEEndUserSession (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a user session ends.

OnWMSEGetParameter (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client sends an RTSP GET_PARAMETER command or the HTTP, or MMS equivalent. (The MMS protocol is not supported in Windows Server 2008 operating systems.)

OnWMSELimitChange (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a property on IWMSServerLimits or IWMSPublishingPointLimits changes.

OnWMSELimitHit (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a publishing point or server limit is reached.

OnWMSELog (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when client logging activity occurs.

OnWMSEOpen (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure immediately after a describe event is raised. If a describe event is not raised, this procedure is called before a client selects content.

OnWMSEPlay (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client requests that the server stream content to it. The server also calls this procedure when a result of a playlist switch event is sent.

OnWMSEPlaylist (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when playlist events occur.

OnWMSEPlugin (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a plug-in is enabled or disabled, or when a plug-in property changes.

OnWMSEPublishingPoint (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a publishing point starts or stops, or when a publishing point property changes.

OnWMSERemoteCacheClose (HR, UserCtx, PresCtx, CmdCtx)

The origin server calls this procedure when a client closes a file on a cache server.

OnWMSERemoteCacheLog (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when logging activity occurs for clients that are accessing cached content.

OnWMSERemoteCacheOpen (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client attempts to open a file on a cache server. The first parameter will indicate whether the attempt was successful.

OnWMSESelectStreams (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client attempts to select content. The first parameter will indicate whether the attempt was successful.

OnWMSEServer (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when the status of the server changes or when a server property changes.

OnWMSESetParameter (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client sends an RTSP SET_PARAMETER command or the HTTP or MMS equivalent. (The MMS protocol is not supported in Windows Server 2008 operating systems.)

OnWMSEStop (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when a client requests that the server stop streaming content to it.

OnWMSEValidatePushDistribution (HR, UserCtx, PresCtx, CmdCtx)

The server calls this procedure when an encoder or distribution server attempts to push content to it. The first parameter will indicate whether the client was authorized to push content to the server.

Each function uses the same parameters, as shown in the following table.

Parameter

Description

HR

An HRESULT that indicates the result of the action. A value of &H00000000 indicates that the event completed successfully. A value of &H80070005 indicates that the client was denied access to the requested action.

UserCtx

An IWMSNamedValues object that contains user context name-value pairs. This is set by the server.

PresCtx

An IWMSNamedValues object that contains presentation context name-value pairs. This is set by the server.

CmdCtx

An IWMSCommandValues object that contains command context request and response. This is set by the server.

The following Visual Basic Scripting Edition (VBScript) example illustrates how to use the event notification callback procedures.

VBScript Example

Dim WMSHeartbeat
' Set the interval to 10 seconds.
WMSHeartbeat = 10000

Dim MyFile

Sub CreateAfile
  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set MyFile = fso.CreateTextFile("c:\wmpub\wmroot\testfile.txt", 8, True)
End Sub

Sub TraceInformation( strTraceText )
    MyFile.WriteLine( strTraceText )
    MyFile.WriteLine
End Sub

Sub PrintContextInformation( tempStr, UserCtx, PresCtx, CmdCtx)
    On Error Resume Next
    tempStr = tempStr & chr(13) & chr(10) & "  User Context:"
    for i = 0 to UserCtx.Count - 1
        tempStr = tempStr & chr(13) & chr(10) & "    " & UserCtx ( i ).Name
        tempStr = tempStr & ": " & UserCtx ( i ).Value
    next
    tempStr = tempStr & chr(13) & chr(10) & "  Presentation Context:"
    for i = 0 to PresCtx.Count - 1
        tempStr = tempStr & chr(13) & chr(10) & "    " & PresCtx ( i ).Name
        tempStr = tempStr & ": " & PresCtx ( i ).Value
    next
    tempStr = tempStr & chr(13) & chr(10) & "  Command Request Context:"
    set Ctx = CmdCtx.Request
    for i = 0 to Ctx.Count - 1
        tempStr = tempStr & chr(13) & chr(10) & "    " & Ctx ( i ).Name
        tempStr = tempStr & ": " & Ctx ( i ).Value
    next
    tempStr = tempStr & chr(13) & chr(10) & "  Command Response Context:"
    set Ctx = CmdCtx.Response
    for i = 0 to Ctx.Count - 1
        tempStr = tempStr & chr(13) & chr(10) & "    " & Ctx ( i ).Name
        tempStr = tempStr & ": " & Ctx ( i ).Value
    next
    set Ctx = Nothing
End Sub

Sub OnWMSPluginInitialize ( ServerCtx )
    CreateAfile
    tempStr = "OnWMSPluginInitialize " & Now
    TraceInformation( tempStr )
End sub

Sub OnWMSPluginHeartbeat ()
    tempStr = "OnWMSPluginHeartbeat " & Now
    TraceInformation( tempStr )
End sub

Sub OnWMSPluginShutdown ()
    tempStr = "OnWMSPluginShutdown " & Now
    TraceInformation( tempStr )
    MyFile.Close
End sub

Sub OnWMSEConnect (HR, UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEConnect " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEDisconnect (HR, UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEDisconnect " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSELogicalURLTransform (HR, UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSELogicalURLTransform " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEPhysicalURLTransform (HR, UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEPhysicalURLTransform " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEDescribe (HR, UserCtx, PresCtx, CmdCtx)
    tempStr = "OnWMSEDescribe " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEOpen( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEOpen " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEClose( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEClose " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSESelectStreams( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSESelectStreams " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEInitializePlaylist( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEInitializePlaylist " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEPlay( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEPlay " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEStop( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEStop " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEClose( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEClose " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEGetParameter( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEGetParameter " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSESetParameter( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSESetParameter " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEValidatePushDistribution( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEValidatePushDistribution " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSECreateDistributionDataPath( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSECreateDistributionDataPath " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEDestroyDistributionDataPath( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEDestroyDistributionDataPath " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSELog( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSELog " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEServer( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEServer " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEPublishingPoint( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEPublishingPoint " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSELimitChange( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSELimitChange " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSELimitHit( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSELimitHit " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSEPlaylist( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSEPlaylist " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSECache( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSECache " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSERemoteCacheOpen( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSERemoteCacheOpen " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSERemoteCacheClose( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSERemoteCacheClose " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

Sub OnWMSERemoteCacheLog( HR, UserCtx, PresCtx, CmdCtx )
    tempStr = "OnWMSERemoteCacheLog " & "HRESULT:" & hr & " " & Now
    PrintContextInformation tempStr, UserCtx, PresCtx, CmdCtx
    TraceInformation( tempStr )
End sub

See Also

Concepts

WMS Active Script Event Handler Plug-in Properties