Registers a listener for open, message, close or error.
The event type.
Receives the event (data of a message, code and reason of a close).
Starts the closing handshake.
Optionalcode: number1000 or a code from 3000 to 4999 (the WHATWG rule).
Optionalreason: stringThe reason text.
Sends a text frame.
The frame.
The part of a WebSocket the gateway uses: the WHATWG interface of the global
WebSocketof Node.js, which thewspackage offers too.