vitalets/websocket-as-promised

How to set header of the ws connection

Closed this issue · 1 comments

I'm adding authentication to ws.

In original websocket:
new WebSocket("ws://www.example.com/socketserver", ["access_token", "3gn11Ft0Me8lkqqW2/5uFQ="]);

I'v searched the APIs of README page but found nothing.
How to use websocket-as-promised to pass params to ws connection.

new WebSocketAsPromised(this.websocketAddress, {
      createWebSocket: (url) => {
        const ws = new WebSocket(this.websocketAddress, ["access_token", "3gn11Ft0Me8lkqqW2/5uFQ="]);
        ws.binaryType = 'arraybuffer';
        return ws;
      },