DomAPI Home
DomAPI

domapi.rpc

 

DomAPI uses a form of remote-scripting for achieving remote procedure calls. Remote-scripting was chosen as the protocol based on a number of factors including browser support, platform support and ease of use.


Events unique to domapi.rpc

Methods unique to domapi.rpc

Properties unique to domapi.rpc


Events
onreceive ( packet )

This event fires after the engine receives a packet from the server. The packet received is passed as the single parameter.
another way to deal with this event is to pass a "handler" function to sendPacket(). Both are legitimate uses. You are free to use either method or both.

Example:
  domapi.rpc.onreceive = function(packet){
  alert("Received packet " + packet.guid);
};
Parameters:
Parameter Type Required Default Description
packet RPCPacket Y     
back to top
onsend ( packet )

This event fires when a packet is dispatched to the server. You can analyze the packet (which is passed as the only parameter) to determine what it contained. Each packet created has a unique guid, which can be used to track it's progress through the engine via the onsend() and onreceive() events.

Example:
  domapi.rpc.onreceive = function(packet){
  if(packet.guid == "GUID_3")alert("Order data sent to server for processing"); 
};
Parameters:
Parameter Type Required Default Description
packet RPCPacket Y     
back to top
ontimeout ( packet )

Fires whenever a packet times out. Passes the packet in question to the handler if defined.

Example:
  domapi.rpc.ontimeout = myCustomTimeoutFunction;
Parameters:
Parameter Type Required Default Description
packet RPCPacket Y     
See also:  timeout
back to top
Methods
receivePacket ( packet )

This method is called by the server code. You do not call it from your client code.
If you would like to interact with the receivePacket() method, see the onreceive() event.

Parameters:
Parameter Type Required Default Description
packet RPCPacket Y   Incoming packet 
back to top
sendPacket( arg ) type : Object

The "arg" parameter fed to this method is an inline Object. See below for accepted parameters.
Any parameters not listed here that you add may also be attached to any returned Object.

This places the passed packet in the send queue. If no other packets were in the queue, it is dispatched immediately, otherwise packets are dispatched on a first-come-first-serve basis.
sendPacket() also accepts an optional handler function. This handler will be fired when the sent packet returns from the server. The incoming packet is also passed to this handler. Handlers are matched to packets by the packet id so it is very important that your server code pass the sent id back in the response packet.

Example:
  var myPacket = new RPCPacket("newCust.cgi/add","Saving new customer");
myPacket.loadFromForm(document.custForm);
myPacket.data.add("cust_added",new Date());
domapi.rpc.sendPacket({
  packet    : myPacket, 
  onreceive : custAdded  //custAdded called on success
});
Available "arg" Parameters:
Parameter Type Required Default Description
packet RPCPacket Y     
onreceive Function     Function call when response is received. The returned packet is passed to it. The domapi.rpc.onreceive event is still fired. 
timeout integer   core.rpc.timeout  Allows you to override the default timeout. 
ontimeout Function     Allows you to provide a custom ontimeout handler. domapi.rpc.ontimeout is still called. 
See also:  onreceive
  onsend
back to top
setCursor ( busy )

Manually changes the cursor. This method is called automatically if manageCursor is true.

Parameters:
Parameter Type Required Default Description
busy boolean   false    
back to top
Properties
charset type : String default value : ISO-8859-1

You can change this to suit your needs.

Example:
  domapi.rpc.charset = "UTF-8";
back to top
doDebug type : boolean default value : false

When true, the engine will display urls it is about to use. It also will not hide the normally hidden IFRAME.
Note that this IFRAME is not created until after the first call to sendPacket().

back to top
lastError type : String

If an error is raised, this contains the last message. Useful for debugging.

back to top
lastUrl type : String

useful for debugging, contains last request sent

back to top
manageCursor type : boolean default value : true

Permits the engine to change the cursor to the "busy" icon when packets are in motion.

back to top
timeout type : integer default value : 30000

The default timeout for sent packets. Defaults to 30 seconds. You can override this for individual packets when sending them.

See also:  ontimeout
back to top
DHTML by www.domapi.com