Partager via


IWMSCacheProxyCallback.OnQueryCache (Visual Basic .NET)

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

IWMSCacheProxyCallback.OnQueryCache(  lHr As Integer,
  Response As WMS_CACHE_QUERY_RESPONSE,
  bstrCacheUrl As String,
  pContentInfo As IWMSContext,
  pCachePluginContext As Object,
  varContext As Object
)

Arguments

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

[in] Member of the WMS_CACHE_QUERY_RESPONSE enumeration type indicating the response of the cache plug-in. This must be one of the following values.

Value

Description

WMS_CACHE_QUERY_HIT_PLAY_ON_DEMAND

The requested content is in the cache and is current. Therefore, it may be streamed from the cache or proxied from an upstream server. Each client request requires a separate connection.

WMS_CACHE_QUERY_HIT_PLAY_BROADCAST

The requested content is in the cache and is current. Therefore, it may be streamed from the cache or proxied from an upstream server. A single stream can be split to multiple downstream clients.

WMS_CACHE_QUERY_HIT_PROCESS_REQUEST

The requested content is in the cache. The server must process the request and send information about the result to the downstream client. 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

The requested content is not in the cache or is not current.

[in] String containing the cache URL.

[in] IWMSContextIWMSContext Object (Visual Basic .NET) containing a Content Description Context.

[in] Object containing information defined by the cache plug-in. The server does not use this information. It passes the pointer back to the plug-in when it calls IWMSCacheProxy.QueryCacheMissPolicy.

[in] Object containing a value defined by the server to identify which call to IWMSCacheProxy.QueryCache the plug-in is responding to when it calls OnQueryCache. 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 content information context identified by the pContentInfo parameter does not exist, and the plug-in returned WMS_CACHE_QUERY_HIT_PLAY_ON_DEMAND in the Response parameter.

0x80070057

The VarContext parameter does not contain a valid reference.

0x80070057

The plug-in returned WMS_CACHE_QUERY_HIT_PROCESS_REQUEST in the Response parameter when the server called QueryCache and specified WMS_CACHE_QUERY_GET_CONTENT_INFO or WMS_CACHE_QUERY_CACHE_EVENT.

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)