Partager via


IWMSCacheProxyCallback.OnQueryCacheMissPolicy (Visual Basic .NET)

The OnQueryCacheMissPolicy method is called by the cache plug-in to respond when the server calls IWMSCacheProxy.QueryCacheMissPolicy.

IWMSCacheProxyCallback.OnQueryCacheMissPolicy(  lHr As Integer,
  CacheMissPolicy As WMS_CACHE_QUERY_MISS_RESPONSE,
  bstrUrl As String,
  pProxyContext As IWMSProxyContext,
  pContentInfo As IWMSContext,
  varContext As Object
)

Arguments

[in] Integer indicating whether the call to IWMSCacheProxy.QueryCacheMissPolicy was successful.

[in] Member of the WMS_CACHE_QUERY_MISS_RESPONSE enumeration type identifying the cache-miss policy of the plug-in. This must be one of the following values.

Value

Description

WMS_CACHE_QUERY_MISS_SKIP

The cache proxy plug-in indicates that it will not process the request. The server queries the next plug-in.

WMS_CACHE_QUERY_MISS_DISCONNECT

The cache proxy plug-in indicates that it will not process the request and that no other plug-in can process it. This forces the server to disconnect the client.

WMS_CACHE_QUERY_MISS_REDIRECT

The cache proxy plug-in indicates that the server must redirect the client to an alternate URL specified by the plug-in. The server does not query the remaining plug-ins.

WMS_CACHE_QUERY_MISS_REDIRECT_TO_PROXY

The cache proxy plug-in indicates that the server must redirect the client to an alternate cache proxy server specified by the plug-in. The client requests the same URL, but through a different proxy.

WMS_CACHE_QUERY_MISS_PLAY_BROADCAST

The cache proxy plug-in directs that the stream be proxied to the client that requested it and shared to other clients that request it.

WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND

The cache proxy plug-in directs that the stream be proxied only to the client that requested it. This can also be used to indicate that a broadcast stream must be sent to a single client.

WMS_CACHE_QUERY_MISS_FORWARD_REQUEST

The cache proxy plug-in directs that the stream be forwarded to an upstream origin server specified by the requested URL. This response is only valid if the server has called QueryCache and specified either WMS_CACHE_QUERY_GET_CONTENT_INFO or WMS_CACHE_QUERY_CACHE_EVENT.

WMS_CACHE_QUERY_MISS_PROCESS_REQUEST

The cache proxy plug-in indicates that it will process the client request. If the server has called QueryCache and specified WMS_CACHE_QUERY_GET_CONTENT_INFO, the plug-in supplies the content information BLOB. If the server has specified WMS_CACHE_QUERY_CACHE_EVENT, the plug-in enables the server to receive the event notice as if it is the origin server. The server can log and process the event.

[in] String containing the URL.

[in] IWMSProxyContextIWMSProxyContext Object (Visual Basic .NET) that enables the server to retrieve client credentials and the name and port number of the proxy server that handles the client request.

[in] IWMSContextIWMSContext Object (Visual Basic .NET) containing content information.

[in] Object containing a value defined by the server to identify which call to IWMSCacheProxy.QueryCacheMissPolicy the plug-in is responding to when it calls OnQueryCacheMissPolicy. You must pass this value back unaltered.

Return Value

This method does not return a value.

If this method fails, it throws an exception.

Number

Description

0x80070057

The VarContext parameter does not contain a valid reference.

0x80070057

The plug-in returned WMS_CACHE_QUERY_MISS_DISCONNECT, WMS_CACHE_QUERY_MISS_REDIRECT_TO_PROXY, or WMS_CACHE_QUERY_MISS_REDIRECT when the server called QueryCache and specified WMS_CACHE_QUERY_LOCAL_EVENT.

0x80070057

The plug-in returned WMS_CACHE_QUERY_MISS_PLAY_BROADCAST or WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND when the server called QueryCache and specified WMS_CACHE_QUERY_GET_CONTENT_INFO or WMS_CACHE_QUERY_LOCAL_EVENT.

0x80070057

The plug-in returned WMS_CACHE_QUERY_MISS_FORWARD_REQUEST when the server called QueryCache and specified WMS_CACHE_QUERY_OPEN.

0x80070057

The plug-in returned WMS_CACHE_QUERY_MISS_PROCESS_REQUEST when the server called QueryCache and specified WMS_CACHE_QUERY_OPEN.

Example

Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices

Public Sub QueryCacheMissPolicy(ByVal OriginUrl As String, _
                                ByVal UserContext As IWMSContext, _
                                ByVal CommandContext As IWMSCommandContext, _
                                ByVal PresentationContext As IWMSContext, _
                                ByVal CachePluginContext As Object, _
                                ByVal lQueryType As Integer, _
                                ByVal Callback As IWMSCacheProxyCallback, _
                                ByVal varContext As Object) _
  Implements IWMSCacheProxy.QueryCacheMissPolicy

    Dim nOpenFlag As Integer
    Dim nGCI As Integer
    Dim nReverseProxy As Integer
    Dim ci As ContentInfo
    Dim ciRP As ContentInfo
    Dim Response As WMS_CACHE_QUERY_MISS_RESPONSE
    Dim ContentInfoContext As IWMSContext

    Try
        nOpenFlag = WMS_CACHE_QUERY_TYPE_FLAGS.WMS_CACHE_QUERY_OPEN
        nGCI = lQueryType And WMS_CACHE_QUERY_TYPE_FLAGS.WMS_CACHE_QUERY_GET_CONTENT_INFO
        nReverseProxy = lQueryType & WMS_CACHE_QUERY_TYPE_FLAGS.WMS_CACHE_QUERY_REVERSE_PROXY

        ' The ContentInfo class is user-defined and includes 
        ' information about a cached item.
        ci = New ContentInfo(OriginUrl, Nothing)

        ' An open request was issued.
        If (nOpenFlag And lQueryType) <> 0 Then
        ' Retrieve content information for the normal proxy mode.
            If nReverseProxy = 0 Then
                ci.CacheProxyCallback = Callback
                ci.varContext = varContext
                CacheProxyServer.GetContentInformation(OriginUrl, _
                                                   PresentationContext, _
                                                   Nothing, _
                                                   Nothing, _
                                                   Me, _
                                                   ci)
            Else
                ' Reverse proxy mode:
                ' Map the requested URL to the reverse proxy URL.
                ' The call to the user-defined GetContentInfo() searches
                ' a reverse proxy ContentInfo object for a
                ' "ReverseProxy" string.
                ciRP = Nothing
                GetContentInfo(OriginUrl, ciRP)
                Response = WMS_CACHE_QUERY_MISS_RESPONSE.WMS_CACHE_QUERY_MISS_PLAY_BROADCAST

                If (ciRP.ContentType And 1) = 0 Then
                    ' Play the content as a broadcast stream.
                    Response = WMS_CACHE_QUERY_MISS_RESPONSE.WMS_CACHE_QUERY_MISS_PLAY_BROADCAST
                Else
                    ' Play the content on demand.
                    Response = WMS_CACHE_QUERY_MISS_RESPONSE.WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND
                End If

                ' Create a content information context. The 
                ' GetContentInfoContext() function is user-defined.
                ContentInfoContext = Nothing
                GetContentInfoContext(ci, ContentInfoContext)

                ' Call OnQueryCacheMissPolicy.
                Callback.OnQueryCacheMissPolicy(0, _
                                                Response, _
                                                ciRP.CacheUrl, _
                                                Nothing, _
                                                ContentInfoContext, _
                                                varContext)
            End If
        End If

        If (nGCI And lQueryType) <> 0 Then
            ' Forward the request upstream.
            Response = WMS_CACHE_QUERY_MISS_RESPONSE.WMS_CACHE_QUERY_MISS_FORWARD_REQUEST
            ContentInfoContext = Nothing
            GetContentInfoContext(ci, ContentInfoContext)
            Callback.OnQueryCacheMissPolicy(0, _
                                            Response, _
                                            OriginUrl, _
                                            Nothing, _
                                            ContentInfoContext, _
                                            varContext)
        End If

        ' A downstream cache proxy server propagated a remote
        ' cache proxy event. Forward the event to an upstream server.
        If (lQueryType And WMS_CACHE_QUERY_TYPE_FLAGS.WMS_CACHE_QUERY_CACHE_EVENT) <> 0 Then
            Callback.OnQueryCacheMissPolicy(0, _
                                            Response, _
                                            Nothing, _
                                            Me, _
                                            Nothing, _
                                            varContext)
        End If

    Catch
        Throw New COMException()
    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

IWMSCacheProxyCallback Object (Visual Basic .NET)