If you want to give your server's clients the capability to use callback objects, you must
define an Interface for the callback object in a Server class.
To define the callback object's Interface, you must take the following steps:
-
Create a class in your server project and name it appropriately (remember the convention
of using the letter I as a prefix to Interface class names).
Set the class Instancing property to Global
MultiUse.
-
Define the Interface class's members (the properties and
methods).
As you will recall, an Interface is a blank class template, so it's not a difficult proposition
to define its properties and methods. Moreover, a callback class really only requires a single
method to implement the callback. An Interface definition of a callback class could therefore
be as simple as the code in Listing 12.21.
LISTING 12.21
A CALLBACK INTERFACE CLASS
'The Class name = INotification
Option Explicit
Public Sub Notify(msg As String)
End Sub
Notice that the code in the listing specifies a String parameter. This would allow the server
to send a message back to the client as part of the notification. It is up to you whether you
want to provide such features in your notification method.
The next section discusses how a client
programmer could use this Interface to implement a callback object and pass it
to the server.