Using the WebSocket constructor is by far the simplest method to do this, but it doesn't provide a way to change the request method from GET to POST (one can only specify the URL and a list of subprotocols, see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket). Regardless, I used this handy automatic way for now.
Using the WebSocket constructor is by far the simplest method to do this, but it doesn't provide a way to change the request method from GET to POST (one can only specify the URL and a list of subprotocols, see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket). Regardless, I used this handy automatic way for now.