Contexts

Contexts are data structures used by the server and plug-ins to store information. Each context contains a list of name-value pairs or properties. The server uses contexts to pass client, server, presentation, cache, content, transport, and command data to the plug-ins. For example, the archive context contains a WMS_ARCHIVE_FILE_SIZE property that identifies the size, in bytes, of a file archived by the server.

You can use the IWMSContext interface to add remove, and retrieve values from a context. Typically, if you are creating a plug-in, you retrieve context properties more than you set them, but if your plug-in creates a local context for temporary storage, you will be setting and retrieving values. The following example illustrates how to retrieve the WMS_COMMAND_CONTEXT_EVENT property from the command context. The property contains a long that identifies an event raised by the server.

C++ Example

HRESULT hr;
IWMSContext *pCtx;
IWMSContext *pCommandCtx;
long l;

   hr = pCommandCtx->GetCommandRequest( &pCtx );
   if SUCCEEDED(hr)
   {
     hr = pCtx->GetLongValue(WMS_COMMAND_CONTEXT_EVENT,
                             WMS_COMMAND_CONTEXT_EVENT_ID, 
                             &l,
                              0 );
   }
   if SUCCEEDED(hr)
   {
      switch( l )
      {
      case WMS_EVENT_PUBLISHING_POINT_ADD:   
      // Add your code here.
      break;
      
      case WMS_EVENT_PUBLISHING_POINT_REMOVE:
      // Add your code here.
      break;
   }

The public context properties described in the following sections are defined in the Wmscontextnames.h file. You retrieve values from a public context by using a predefined enumeration member and an associated key. The server resolves the enumeration value to a reference to the name of the property, and it uses the key to speed the search for the property value. In the preceding example, the enumeration member is WMS_COMMAND_CONTEXT_EVENT, and the key is WMS_COMMAND_CONTEXT_EVENT_ID. Typically, a key is made up of the enumeration member followed by _ID.

Context

Description

Archive Context

Contains information about an archived file.

Cache Content Information Context

Contains information about a cache.

Command Context

Contains information used by the server to describe a single command issued by the end user. The command context itself contains two contexts, a request context and a response context.

Content Description Context

Contains information about the content.

Presentation Context

Contains information about the stream.

Server Context

Contains information about the server.

Transport Context

Contains information about the network protocol.

User Context

Contains information about the client.

See Also

Concepts

Custom Plug-in Basics