Callbacks not removed from queue?

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

simpleSimon
Posts: 10
Joined: 03 Mar 2016, 21:07

Callbacks not removed from queue?

Postby simpleSimon » 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"

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);
}
simpleSimon
Posts: 10
Joined: 03 Mar 2016, 21:07

Re: Callbacks not removed from queue?

Postby simpleSimon » 18 Mar 2016, 19:15

Never mind. I figured it out. Listeners are added as a list even when they are duplicate. I add a listener every time I click the listen button.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Callbacks not removed from queue?

Postby Lapo » 19 Mar 2016, 14:23

Yes, that's correct :)
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 17 guests