Share via


IWMSCacheProxyCallback.OnAddCacheItem (C#)

banner art

Previous Next

IWMSCacheProxyCallback.OnAddCacheItem (C#)

The OnAddCacheItem method is called by the cache plug-in to respond when the server calls IWMSCacheProxy.AddCacheItem. The AddCacheItem method prestuffs a cache.

Syntax

  

Parameters

lHr

[in] int indicating whether the call to IWMSCacheProxy.AddCacheItem was successful.

pCacheItemDescriptor

[in] IWMSCacheProxyCallback object containing the callback function.

varServerContext

[in] object containing a value defined by the server to identify which call to AddCacheItem the plug-in is responding to when it calls OnAddCacheItem. The plug-in must pass this value back unaltered.

Return Values

This method does not return a value.

Example Code

using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;

void IWMSCacheProxyServerCallback.OnDownloadContentFinished(
                                    int lHr,
                                    object[] psaArchiveContexts,
                                    object varContext)
{
  try
  {
    // The plug-in's call to IWMSCacheProxyServer.DownloadContent
    // succeeded.
    if(lHr==0)
    {
      // Retrieve the user-defined ContentInfo object from 
      // varContext parameter.
      ContentInfo ci = (ContentInfo)varContext;

      if(psaArchiveContexts.Length!=0) 
      {
        // The content is not a playlist.
        if((ci.ContentType & 2)==0)
        {
          IWMSContext ArchiveContext = (IWMSContext)psaArchiveContexts.GetValue(0);

          // Retrieve the file name. The server can change
          // file names to avoid a naming collision.
          string CacheFile;
          ArchiveContext.GetStringValue(WMSDefines.WMS_ARCHIVE_FILENAME,
                                        WMSDefines.WMS_ARCHIVE_FILENAME_ID,
                                        out CacheFile,
                                        0);
          ci.CacheUrl = CacheFile;
        }
        // Save the playlist.
        else
        {
          // Call the user-defined function, SavePlaylist().
          SavePlaylist(ci);
        }
        UpdateTable(ci);
      }

      // Call OnAddCacheItem() to inform the server
      // that content was successfully downloaded.
      CacheProxyCallback.OnAddCacheItem( lHr,
                                         null,
                                         varContext);
     }
  }

  catch(Exception e)
  {
    throw new COMException();
  }

    return;
}

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