W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

[Bug 13763] The WebSocket API should provide a polling mechanism too. Only event based capture messages is not good because if a method in a JS-Class send a message the reply arrive in the event handler. The event handler has no access (if no global var exists) to th

From: <bugzilla@jessica.w3.org>
Date: Sat, 13 Aug 2011 02:45:44 +0000
To: public-webapps@w3.org
Message-Id: <E1Qs4EK-0003rV-Ux@jessica.w3.org>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=13763

Ian 'Hixie' Hickson <ian@hixie.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ian@hixie.ch
         Resolution|                            |WONTFIX

--- Comment #6 from Ian 'Hixie' Hickson <ian@hixie.ch> 2011-08-13 02:45:44 UTC ---
It's easy to do this already:

   var queue = [];
   websocket.onmessage = function (event) {
     if (queue.length)
       queue.shift()(event);
   };

   // to send and then wait for response:
   websocket.send('foo');
   queue.push(function (event) {
     // rest of function goes here
   });

...or some such. Basically works like polling but without having to worry about
missing other events if you have other things going on.

(code above is untested so may have syntax errors)

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Received on Saturday, 13 August 2011 02:45:46 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:47 GMT