|
|||||||||
| PREV NEXT | FRAMES NO FRAMES | ||||||||
See:
Description
| Packages | |
|---|---|
| barracuda.authentication | |
| barracuda.eh | |
| barracuda.pipe | |
The Java EventHandler is a client protocol stack compatible with the Barracuda Embedded Web-Server EventHandler plugin. Unlike the JavaScript client EventHandler Stack, the java EventHandler uses a binary protocol when communicating with the Barracuda Embedded Web-Server EventHandler plugin.
The Barracuda Embedded Web-Server EventHandler plugin can simultaneously communicate with binary EventHandler clients and clients using the text based protocol, such as the JavaScript client EventHandler Stack. This is transparent to user code using the EventHandler Stack in the server. Thus, a server EventHandler interface can therefore handle persistent connections from any EventHandler client. The great thing is that your server interface code does not see the difference between a DHTML rich client user interface connection and a Java application connection.
The Java EventHandler Stack can be used with or without stub code produced by the EventHandlerCompiler, though it is safer to create interfaces using the EventHandlerCompiler. The raw EventHandler API is useful for sending data with a dynamic number of arguments and/or dynamic argument type content.
The EventHandlerCompiler can create Java stub code, which you can plug into the EventHandler. The EventHandlerCompiler flag -J <P> produces Java code. P is the package name. You can use a '.' if you do not want to create a package name.
The EventHandlerCompiler creates one Java class for each 'server' interface and two classes for each 'client' interface. Let's say we have the following Event Handler Interface (ehi) file:
MyInterface.ehi:
client DoClient { doit { } }
server DoServer { doit { } }
EventHandlerCompiler -J . MyInterface.ehi produces:
DoClient.java, DoClientDecode.java, and DoServer.java
The DoClient class is a Java interface. You must create a class that implements the doit method in this interface. The DoClientDecode class is the interface between the raw EventHandler data and the methods in the DoClient class. The DoClientDecode class extracts the raw data received from the EventHandler and calls the doit method in the DoClient implementation.
//Setting up the receive interface:
InterfaceContainer ifc = new InterfaceContainer();
//DoClientImpl is the class implementing the method in DoClient
DoClientDecode doClient = new DoClientDecode(new DoClientImpl());
doClient.insertInto(ifc); //Register with the interface container
//Create the EventHandler
EventHandler eventHandler = new
EventHandler("http://127.0.0.1:9357/path2/EventHandler",
new OnDisconnect(), // My on disconnect interface
ifc, // Bind the InterfaceContainer to the EventHandler
null);
//Setting up the 'send' interface:
DoServer doServer = new DoServer(eventHandler);
try {
//Connect to server
eventHandler.connect();
//Send data to server
doServer.doit();
}
catch(IOException e) {
System.err.println("Bugger");
System.exit(1);
}
The Java EventHandler Stack can handle the same types as the JavaScript EventHandler Stack, i.e. int, long, double, string, int[], long[], double[] and string[]. In addition, the Java EventHandler stack can handle byte arrays (byte[]). Please note that byte arrays cannot be handled by the JavaScript EventHandler Stack. Therefore, interfaces used by both DHTML clients and Java clients should not use byte arrays.
|
|||||||||
| PREV NEXT | FRAMES NO FRAMES | ||||||||