Share via


Setting Publishing Point Limits

banner art

Previous Next

Setting Publishing Point Limits

By setting publishing point limits, you can control and distribute resource usage across multiple publishing points. For example, you can put limits on one publishing point to ensure enough available resources for a higher priority publishing point. Use the IWMSPublishingPointLimits object to specify and retrieve these limit values.

The following examples illustrate how to control resource usage per publishing point by setting various publishing point limit values.

Visual Basic .NET Example

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

' Declare variables.
Dim Server As WMSServer
Dim Limits As IWMSPublishingPointLimits
Dim lCount As Long
Dim i As Long

Try
    ' Create the WMSServer object and retrieve the
    ' number of publishing points.
    Server = New WMSServer()

    lCount = Server.PublishingPoints.Count

    ' Set limits for each publishing point.
    For i = 0 To (lCount - 1)
        ' Retrieve the IWMSPublishingPointLimits object.
        Limits = Server.PublishingPoints.Item(i).Limits
        ' Set the maximum number of connected clients.
        Limits.ConnectedPlayers = 10
        ' Set the maximum bandwidth usage for each client.
        Limits.PerPlayerConnectionBandwidth = 128
        ' Set the maximum content-delivery rate for each client.
        Limits.PlayerCacheDeliveryRate = 5000
    Next

Catch errCom As COMException
    ' TODO: Handle COM exceptions.
Catch err As Exception
    ' TODO: Exception handler goes here.
Finally
    ' TODO: Clean-up code goes here.
End Try

C# Example

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

WMSServer Server;
IWMSPublishingPointLimits Limits;
long lCount;
int i;

try
{
    // Create the WMSServer object and retrieve the
    // number of publishing points.
    Server = new WMSServerClass();

    lCount = Server.PublishingPoints.Count;

    // Set limits for each publishing point.
    for (i = 0; i < lCount; i++)
    {
        // Retrieve the IWMSPublishingPointLimits object.
        Limits = Server.PublishingPoints[i].Limits;

        // Set the maximum number of connected clients.
        Limits.ConnectedPlayers = 10;

        // Set the maximum bandwidth usage for each client.
        Limits.PerPlayerConnectionBandwidth = 128;

        // Set the maximum content-delivery rate for each client.
        Limits.PlayerCacheDeliveryRate = 5000;
    }
}
catch (COMException comExc)
{
    // TODO: Handle COM exceptions.
}
catch (Exception exc)
{
    // TODO: Exception handler goes here.
}
finally
{
    // TODO: Clean-up code goes here.
}

C++ Example

#include <windows.h>
#include <atlbase.h>    // Includes CComVariant.
#include "wmsserver.h"

// Declare variables and interfaces.
IWMSServer                *pServer;
IWMSPublishingPoints      *pPubPoints;
IWMSPublishingPoint       *pPubPoint;
IWMSPublishingPointLimits *pLimits;

HRESULT         hr;
CComVariant     varIndex;
long            lCount;
int             x;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSPublishingPoints
// interface and retrieve the number of publishing
// points.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;
hr = pPubPoints->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;

// Set limits for each publishing point.
for (x = 0; x < lCount; x++)
{   
    // Retrieve a pointer to the next
    // IWMSPublishingPoint interface.
    varIndex = x;
    hr = pPubPoints->get_Item(varIndex, &pPubPoint);
    if (FAILED(hr)) goto EXIT;

    // Retrieve a pointer to the IWMSPublishingPointLimits
    // interface.
    hr = pPubPoint->get_Limits(&pLimits);
    if (FAILED(hr)) goto EXIT;

    // Set the maximum number of connected clients.
    hr = pLimits->put_ConnectedPlayers(10);
    if (FAILED(hr)) goto EXIT;

    // Set the maximum bandwidth usage for each client.
    hr = pLimits->put_PerPlayerConnectionBandwidth(128);
    if (FAILED(hr)) goto EXIT;

    // Set the maximum content-delivery rate for each client.
    hr = pLimits->put_PlayerCacheDeliveryRate(5000);
    if (FAILED(hr)) goto EXIT;

    // Release objects.
    pPubPoint->Release();
    pLimits->Release();
}

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

See Also

Previous Next