Use ws for http, wss for https

Looks like we're actually going to need this
I think you should use `global` here instead of `window` for better support with browserify.