title: Websocket return from function
body: <p>im trying to use websockets for my application</p>
  
  <pre><code>function Connector()
  {
    this.protocol = "bla";
    this.socket   = new WebSocket("ws://echo.websocket.org", this.protocol);
  }
  
  Connector.prototype.emit = function()
  {
    this.socket.send('abc');
  }
  </code></pre>
  
  <p>For me it is possible to call: </p>
  
  <pre><code>var con = new Connector();
  con.emit();
  </code></pre>
  
  <p>from my Browsers console but from source code i get the following error message</p>
  
  <pre><code>InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable
  </code></pre>
  
  <p>what is the problem ?</p>