client Function Namespace APE.Request.cycledStack

Summary

File
<./src/Ape_Jsf/Source/Request/Request.CycledStack.js>

cycledStack Function Namespace Detail

APE.Request.cycledStack ()
Request.cycledStack object APE JSF allows you to create "cycled stacks" of request. These methods are very useful for example if your application must send different commands to APE server from several functions (or not) and you want to send them all at once. With request.cycledStack you don't have to care when the command are sent. They are automatically sent (by default each 350ms). This is verry useful for peridical stuff. Or to reduce/optimze bandwith.
File:
<./src/Ape_Jsf/Source/Request/Request.CycledStack.js>
See:
APE.Request.stack
APE.request.stack
pipe.stack

Summary

Own
Methods Attributes Methods Name Methods Description
<static>   APE.Request.cycledStack. add (cmd, params, options) Add a command to cycled request stack
<static>   APE.Request.cycledStack. send () Force the sending of the request stack
<static>   APE.Request.cycledStack. setTime (time, now) Change cycled stack time.

<static> {void} APE.Request.cycledStack. add (cmd, params, options)

Add a command to cycled request stack
Parameters:
{Array|string} cmd If the argument is a string, it should be a CMD (e.g. 'CONNECT'). If the argument is an array: the array should contain objects with cmd, params and sessid)
{object} params Optional The parameters that must be send with the command
{object} options Optional Object with request options
{boolean} options.sessid Optional Default: true Add the sessid property to the request
Returns:
{void} The request object
Example
//ape var is a reference to APE instance
//Note : this example use the server module mouseMotion available on APE Store
// capture mousemove event
document.onmousemove=getMouseCoordinates;
//Add to the cycled Stack the position of the mouse, and the time
function getMouseCoordinates(event) {
	ev = event || window.event;
	ape.request.cycledStack.add('mouseMotion', {"x":ev.x, "y":ev.y});
	captureMouse = false;
}
//Intercept mouseMotion raw, and display where the mouse was
ape.onRaw('mouseMotion', function(data) {
	console.log('Mouse position, x : ' + data.x + ' / y : ' + data .y);
});
See:

<static> APE.Request.cycledStack. send ()

Force the sending of the request stack
Example
//ape var is a reference to APE instance
//Add two request to the stack
ape.request.cycledStack.add('testCommand', {"param1":"value"});
ape.request.cycledSstack.add('anotherCommand', {"param1":"value"});
//Imediately send the stack to APE server
ape.request.cycledStack.send();
See:

<static> APE.Request.cycledStack. setTime (time, now)

Change cycled stack time. By default request added through request.cycledStack.add are sent each 350ms. This function allow you to ajust this time.
Parameters:
{integer} time New cycle interval in ms
{boolean} now Optional Default: false Send immediately
Example
//ape var is a reference to APE instance
//Set cycle stack time to 100 ms
ape.request.cycledStack.setTime(100);