title: How to create a Websocket Client with Chrome Extensions?
body: <p>I'm trying to create a WebSocket client on Chrome Extensions/Chrome Packaged Apps, that behaves like <a href="https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo?hl=en" rel="noreferrer">Simple WebSocket Client</a> from hakobera, or <a href="https://chrome.google.com/webstore/detail/dark-websocket-terminal/cpopfplgicdljhakjpdochbbiodlgaoc?hl=en" rel="noreferrer">Dark Websocket Terminal</a> from toni.ruottu on Chrome Web Store. </p>
  
  <p>I've been trying to add below code into my Chrome Extensions, but cannot even get any connection working. (my pywebsocket extension on appache runs on localhost)</p>
  
  <pre><code>var ws;
  if ("WebSocket" in window) {
    ws = new WebSocket("ws://localhost");
    ws.onopen = function() {
      ws.send("hello");
    };
  }
  </code></pre>
  
  <p>Should I put something special in manifest file? Or should I use other methods to establish a connection within Chrome Extensions? Some code examples or sample projects would be really appreciated. </p>
  
  <p>Thanks!</p>