Microsoft Chat Server Development Guide

Generic Bindings

Event bindings are implemented directly within the chat server objects to efficiently fix the lifetime of the binding to the lifetime of the object. However, if the extension creates the same binding for all user objects, it is much more efficient to issue a single binding call.

By passing NULL (or Nothing in Visual Basic) as the target object, it is possible to create a binding that triggers the associated callback notification for all objects. This type of binding would be used if the extension needed to monitor all users or all channels, for instance. Likewise, you can pass an empty string as the event name to create a single binding for all events. The following example demonstrates how to bind to the OnNickChanged event for all chat users:

Private Function IChatExtensionCallBack_Init( _
    ByVal Server As CHATSVCLib.IChatServer, _
    ByVal Registrar As CHATSVCLib.IChatRegistrar) As Long
    Set g_Registrar = Registrar          ' Keep global copy

    ' Bind to the OnNickChanged notification for all users
    If Not g_Registrar Is Nothing Then
        g_Registrar.AddUserEvent "OnNickChanged", Nothing
    End If

    ' Return zero to indicate successful initialization
    IChatExtensionCallBack_Init = 0
End Function

By combining these two formats (empty string and NULL), the extension can bind to all events for all objects of a specific type. Due to obvious performance implications, this type of binding should be avoided unless absolutely necessary.


© 1998 Microsoft Corporation. All rights reserved.