Microsoft Chat Server SDK Reference

The Chat Server Object Model

The chat server is represented by its own object model. Each aspect of the server, such as a user or a channel, is defined as an object. The following table describes each of the objects in the chat server object model.

Object Description
ChatAccessEntries A collection of ChatAccessEntry objects.
ChatAccessEntry These objects are used to define the access control mask for the server, channel, and user. All actions performed on the server are restricted by access control entries.
ChatChannel This object defines methods and properties that manipulate and define a chat channel.
ChatChannels A collection of ChatChannel objects.
ChatServer This object defines the methods and properties relating to a chat server. It also includes properties that allow access to collections of chat channels and users. This is the root object in the chat server object model.
ChatUser This object defines methods and properties that manipulate and define a chat user.
ChatUsers A collection of ChatUser objects.

You can create a reference to the ChatServer root object explicitly by using a Progid ("ChatServer.ChatServer.1") or a CLSID ("{5c665462-3eb5-11d109426-00aa0064d470}"). Alternately, you can use the reference to an existing ChatServer object that is passed into some Chat Server Extensibility API callback methods. In Microsoft® Visual Basic®, early bindings to the ChatServer object can also be created as follows:

Dim ChatSvc As New CHATSVCLib.ChatServer

Note: To use the chat server objects from Visual Basic, you must add a reference to the "Microsoft Exchange Chat Server Extensibility 1.0 Library."

Using Collections

Most collections support the use of numeric indexes or string keys, the strings returned by the default property of the objects contained in the collection. The default property for the ChatUser object is the Nick property; for ChatChannel it is the Name property.

For all collections, the Item property is the default property, which makes it possible to retrieve objects from the collection using a simplified collection lookup syntax. For example, the following two lines of Visual Basic code are functionally identical:

Set User = ChatServer.Users.Item("Nick")
Set User = ChatServer.Users("Nick")

You can also use a Visual Basic For Each…Next loop to iterate through all objects in the collection. The following example shows how this is done:

Dim Entry As CHATSVCLib.IChatAccessEntry
For Each Entry In ChatServer.AccessEntries
   Debug.Print Entry.Mask
Next

Note to C++ Developers: The For Each…Next syntax is made possible by a "hidden" interface method, _NewEnum. In addition to the Item property, this method can be used to return each item in the collection. The following example demonstrates how to use this interface:

CComPtr<IUnknown> pUnk; 
CComQIPtr<IEnumVARIANT, &IID_IEnumVARIANT> pNewEnum; 
if (SUCCEEDED(pChannels->get__NewEnum(&pUnk)) && pUnk != NULL) { 
   pNewEnum = pUnk;
   VARIANT varChannel; 
   CComQIPtr<IChatChannel, &IID_IChatChannel> pChannel;
   while (pNewEnum->Next(1, &varChannel, NULL) == S_OK) { 
      ASSERT (varChannel.vt == VT_DISPATCH); 
      pChannel = V_DISPATCH(&varChannel); 
.
.
.
      VariantClear(&varChannel); 
   } 
}

© 1998 Microsoft Corporation. All rights reserved.