IWMSCacheProxy.AddCacheItem (Visual Basic .NET)
Previous | Next |
IWMSCacheProxy.AddCacheItem (Visual Basic .NET)
The AddCacheItem method is called by the server to prestuff a cache.
Syntax
Parameters
bstrOriginUrl
[in] String containing the URL on the origin server of the content to be cached.
bstrPrestuffUrl
[in] String containing the URL identifying the location for the cache. If NULL, the method uses bstrOriginUrl.
lExpiration
[in] Integer
containing the amount of time, in seconds, that the cache item is available to be streamed after it has been cached. For example, a value of 86,400 indicates that cached content can be streamed for 24 hours after it is downloaded from the origin server.
lBandwidth
[in] Integer
containing the maximum bandwidth that the server can use when streaming content into cache storage.
lRemoteEventFlags
[in] Integer
containing the remote events that must be passed back to the origin server. This must be one of the following values from the WMS_EVENT_TYPE enumeration.
Event | Description |
WMS_EVENT_REMOTE_CACHE_OPEN | A remote cache proxy server has opened cached content or established a connection to an upstream server. |
WMS_EVENT_REMOTE_CACHE_CLOSE | A remote cache proxy server has closed a content file or disconnected a client from an upstream server. |
WMS_EVENT_REMOTE_CACHE_LOG | A client submitted a rendering log to indicate that it streamed content from a local cache, or a cache proxy server submitted a remote log to indicate that it either streamed content from cache or proxied it from an upstream server. |
pCallback
[in] IWMSCacheProxyCallback object containing the callback function. This can be Nothing if no callback is requested.
varContext
[in] Object containing a value defined by the server to identify which call to AddCacheItem the plug-in is responding to when it calls IWMSCacheProxyCallback.OnAddCacheItem. The plug-in must pass this value back unaltered.
Return Values
This method does not return a value.
Remarks
This method can be called whenever an item must be added to a cache. It is always called by the server when the IWMSCacheProxyPlugin.PreStuff method is called. The plug-in calls IWMSCacheProxyCallback.OnAddCacheItem to respond to the AddCacheItem method.
Example Code
Imports Microsoft.WindowsMediaServices.Interop Imports System.Runtime.InteropServices Imports Microsoft.WindowsMediaServices.Interop Imports System.Runtime.InteropServices Public Sub AddCacheItem(ByVal OriginUrl As String, _ ByVal PrestuffUrl As String, _ ByVal lExpiration As Integer, _ ByVal lBandwidth As Integer, _ ByVal lRemoteEventFlags As Integer, _ ByVal Callback As IWMSCacheProxyCallback, _ ByVal varContext As Object) _ Implements IWMSCacheProxy.AddCacheItem Dim ci As ContentInfo Dim PresentationContext As IWMSContext Dim pUnknown As IntPtr Try ' The ContentInfo class is user-defined and contains ' information about cached content. ci = New ContentInfo(OriginUrl, PrestuffUrl) ci.lExpiration = lExpiration ' Create a presentation context. The CacheProxyServer ' object is your plug-in's implementation of the ' IWMSCacheProxyServer object. ClassObject.AllocIWMSContext( _ GetType(IWMSContext).GUID, _ WMS_CONTEXT_TYPE.WMS_USER_CONTEXT_TYPE, _ Nothing, _ pUnknown) PresentationContext = Marshal.GetTypedObjectForIUnknown( _ pUnknown, _ GetType(IWMSContext)) ' Retrieve content information. CacheProxyServer.GetContentInformation(OriginUrl, _ PresentationContext, _ Nothing, _ Nothing, _ Me, _ ci) ' The server calls OnGetContentInformation() in response ' to the preceding call and sends the plug-in a cache ' information context. The context contains a reference to ' an IWMSDataContainerVersion object that the plug-in can use ' to retrieve content information and place it in the ' user-defined ContentInfo class. If the ' WMS_DATA_CONTAINER_VERSION_CACHE_FLAGS enumeration member ' indicates that the content can be downloaded, the plug-in calls ' DownloadContent(). When the download is complete, the ' OnGetContentInformation() function can call OnAddCacheItem() to ' signal that the appropriate event notices should be raised. 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
Previous | Next |