title: HTML5 Websocket within Webworker
body: <p>I've managed to get websockets working inside a webworker using Chrome, but only for receiving data. When I try to send data I get a DOM Exception, has anyone managed to send data?</p>
  
  <p>This is what I have for my web worker.</p>
  
  <pre><code>self.addEventListener('message', function(e) {
  var data = e.data;
  
  switch (data.cmd) {
      case 'init':
          self.postMessage("Initialising Web Workers...");
          testWS();
          break;
      default:
          self.postMessage('Unknown command: ' + data.msg);
      };
  }, false);
  
  function testWS() {
      var connectionAddr = "ws://localhost:8003";
      var socket = new WebSocket(connectionAddr);
      socket.onmessage = function(event) {
          self.postMessage('Websocket : ' + event.data);
      };
  
      socket.onclose = function(event) {
      };
  
      function send(message) {
          socket.send(message);
      }
  
      send("hello"); //Here is where the exception is thrown
  }
  </code></pre>