Custom Drivers Callback Methods API
A few callback methods are called by the HSYCO core engine during initialization, exit, and for normal operations.
You should write your custom interface code inside these methods, and also set the default values of some static properties.
Contents
Static Properties
DEFAULTSOCKETPORT
DEFAULTSOCKETPORT
Used to set the default IP socket port, to be used when the port field is not set in the configuration. For example, if your driver is interfacing an HTTP-based service, you may want to set DEFAULTSOCKETPORT to 80.
COMMANDSQUEUESIZE
COMMANDSQUEUESIZE
Defines the size of the command queue.
The command queue is used to accumulate commands that the driver should execute, and are generated by ioSet() JavaScript or Java calls, the IOSET event or users pressing (button) objects in the Web user interface.
The command queue should be large enough to let the driver have time to consume incoming commands and not lose any. At the same time a queue that is too large could let a large number of messages to accumulate in case the driver has temporary issues talking to the external system.
HSYCO's built-in drivers usually have queue sizes between 64 and 1024. 256 is normally a good value.
SHUTDOWNWHENSLAVE
SHUTDOWNWHENSLAVE
This is the default value of the "shutdown when inactive" configuration parameter. If true and the "shutdown when inactive" is not defined, the driver will be automatically shut down when the HSYCO server is in a high availability configuration and the server is not the active server.
Callback Methods
init
boolean init(String name, HashMap<String, String> config)
Called once every time the driver is started.
Returning false will fail the initialization procedure, and the driver will not start.
loop
boolean loop()
Called repeatedly while the driver should be alive.
Returning false will not update the keep-alive timer, causing the driver to quit after a while.
This call should always return within about 30 seconds, to avoid the keep-alive watch-dog intervention.
end
boolean end()
Called once when the driver quits after it has started correctly.
Should always return true.
user
String user(String session, String user, String id, HashMap<String, String> fields)
Called on user keys, gui input objects, submit and user action in Events or Java, when the user interface object identifier has a prefix that matches the driver's identifier followed by a "." character.
This method is optional, and doesn't need to be implemented if not required.
command
void command(String name, String value)
Called for each command that should be processed by the driver.
This method is optional, and doesn't need to be implemented if not required.