Callbacks not removed from queue?
Posted: 18 Mar 2016, 18:53
I have written a server side extension and when I send an ExtensionRequest to it with javascript my callback is called once. But when I send to it a single time again, my callback is called twice. If I send to it again, my callback is called three times, and so on. Am I supposed to flush the response list some how? I have a little test form that has a button as follows:
<button type="button" onclick="listen('WK1234')">listen</button><br/><br/></body>
On the button click, a counter is initialized to count the callbacks. (code snippet follows). The results are:
click button the first time --> alert "responded (1): OK"
click button a second time --> alert "responded (1): OK" followed by alert "responded (2): OK"
click button again -> alert "responded (1): OK" followed by alert "responded (2): OK" followed by alert "responded (3): OK"
<button type="button" onclick="listen('WK1234')">listen</button><br/><br/></body>
On the button click, a counter is initialized to count the callbacks. (code snippet follows). The results are:
click button the first time --> alert "responded (1): OK"
click button a second time --> alert "responded (1): OK" followed by alert "responded (2): OK"
click button again -> alert "responded (1): OK" followed by alert "responded (2): OK" followed by alert "responded (3): OK"
Code: Select all
function listen(uid)
{
responseCounter = 0;
sfs.addEventListener(SFS2X.SFSEvent.EXTENSION_RESPONSE, onListenResponse.bind(this), this);
var params = {};
params.uid = uid;
sfs.send(new SFS2X.Requests.System.ExtensionRequest("listen", params));
}
function onListenResponse(evtParams)
{
this.responseCounter++;
alert("responded (" + this.responseCounter +") : " + evtParams.params.result);
}