[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

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 UTC