|
The JavaScript EventHandler Stack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Object | +--EventHandler
Defined in eh.js
| Field Summary | |
Object |
$pc
|
Object |
$pcr
|
Object |
$pwd
|
Object |
$statusIntf
|
Object |
$user
|
| Constructor Summary | |
EventHandler(statusIntf, url, cfg)
The JavaScript EventHandler is a client protocol stack compatible with the Barracuda Embedded Web-Server EventHandler plugin. |
|
| Method Summary | |
void
|
addInterface(intfObj, intfName)
|
void
|
close()
Close the persistent connection. |
void
|
connect()
Initiate the persistent connection sequence. |
void
|
destructor()
Release all resources used by the EventHandler. |
Object
|
isConnected()
Returns true if a persistent connection is active. |
void
|
sendData(intf, method, data)
|
| Field Detail |
Object $pc
Object $pcr
Object $pwd
Object $statusIntf
Object $user
| Constructor Detail |
EventHandler(statusIntf, url, cfg)
The JavaScript EventHandler is a client protocol stack compatible with the Barracuda Embedded Web-Server EventHandler plugin. The protocol used by the JavaScript EventHandler is text based. The protocol is similar to URL-encoded data upstream and the downstream data (the PushConnection) is sent in the JSON format.
Example of how to create an instance of the EventHandler:
var eh;
try {
eh = new EventHandler(
new EhStatus,
'/path2/EhDirInstance',
//Optional parameter. Normally not used.
{user:'Winnie', password:'phoo'}
);
eh.connect();
}
catch(e) { alert(e.toString()); }
The EventHandler protocol is designed such that it can transport the following numbers: int, long, and double. JavaScript cannot differentiate between these types; in JavaScript one simply uses 'number'. The client protocol stack tags numbers as follows:
if: N<= 2147483647 && N>= -2147483648 -> int else if: floating point -> double else: -> long
The EventHandler stub code created by the EventHandlerCompiler for the server side code can automatically convert any number argument to its type defined in the 'Event Handler Interface' file.
Status interface example. See parameter 'statusIntf' below:
//Create an instance of EhStatus and use the instance as the first
//parameter in the EventHandler constructor.
function EhStatus()
{
};
EhStatus.prototype.onConnect=function(cid, pushConType)
{
alert("Connected to server. Connection ID="+cid+
"Connection type="+pushConType);
};
EhStatus.prototype.onDisconnect=function(e)
{
alert(e.toString());
};
EhStatus.prototype.onError=function(e)
{
alert(e.toString());
};
EhStatus.prototype.onTrace=function(msg)
{
alert(msg);
};
parameter 'cfg':
user: string. The user name.
password: string. The user password.
path2Eh: string. Path to the Client side EH code. Default is /rtl/eh.
Example: {user:'Winnie', password:'phoo'}
statusIntf - an object with an onConnect, onDisconnect, and onError method and an optional onTrace method. See example above.
url - path to the EhDir instance in the server.
cfg - Optional parameter. This is an object with key value pairs. See explanation below.
eCode range 1200 - 1249
Keys in the 'cfg' parameter object:
User and password
User and password are normally not needed as a user is normally authenticated by the origin server prior to setting up the persistent EventHandler connection. User and password may be required for more advanced use of the EventHandler, such as when connecting to another server than the origin server. Cross-domain scripting is by default disabled in all browsers. You can change your browsers security settings to allow cross-domain scripting. If your browser is Internet Explorer it is in Internet Options > Security > Internet Zone > Custom Level > Miscellaneous > Access data sources across domains : enable
| Method Detail |
void addInterface(intfObj, intfName)
void close()
void connect()
You do not have to wait for the connection to be established before sending data. The EventHandler adds all messages sent to the server to an internal queue. The messages in the queue are automatically sent to the server when the persistent connection is established.
void destructor()
Object isConnected()
void sendData(intf, method, data)
|
The JavaScript EventHandler Stack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||