I'm trying to create a WebSocket client on Chrome Extensions/Chrome Packaged Apps, that behaves like Simple WebSocket Client from hakobera, or Dark Websocket Terminal from toni.ruottu on Chrome Web Store.
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)
var ws;
if ("WebSocket" in window) {
ws = new WebSocket("ws://localhost");
ws.onopen = function() {
ws.send("hello");
};
}
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.
Thanks!
port number in ws://
andprotocol
in web socket object instantiation line. – Brancusi