GatewayHelper class

ColdFusion MX includes a coldfusion.eventgateway.GatewayHelper Java marker interface. You implement this interface to define a class that provides gateway-specific utility methods to the ColdFusion application or listener CFC. For example, an instant messaging event gateway might use a helper class to provide buddy list management methods to the application.

The Gateway class must implement a getHelper method that returns the helper class or null (if the gateway does not need such a class).

ColdFusion applications call the GetGatewayHelper CFML function, which invokes gateway's the getHelper method to get an instance of the helper class. The application can then call helper class methods using ColdFusion object dot notation.

The following code defines the SocketHelper class, the gateway helper for the SocketGateway class. It has an empty constructor and two public methods: one returns the socket IDs; the other closes a specified socket. These classes let an application monitor and end session connections.

public class SocketHelper implements GatewayHelper {
   public SocketHelper() {
   }
   public coldfusion.runtime.Array getSocketIDs () {
      coldfusion.runtime.Array a = new coldfusion.runtime.Array();
      Enumeration e = socketRegistry.elements();
      while (e.hasMoreElements()) {
         a.add(((SocketServerThread)e.nextElement()).getName());
       }
       return a;
    }
   public boolean killSocket (String socketid) {
      try
      {
         ((SocketServerThread)socketRegistry.get(socketid)).socket.close();
         ((SocketServerThread)socketRegistry.get(socketid)).socket = null;
         socketRegistry.remove(socketid);
         return true;
      }
      catch (IOException e) {
         return false;
      }
   }
}

View comments in LiveDocs