* WebSocket transport * * @param {EngineRequest} req
(req: EngineRequest)
| 15 | * @param {EngineRequest} req |
| 16 | */ |
| 17 | constructor(req: EngineRequest) { |
| 18 | super(req); |
| 19 | this.socket = req.websocket; |
| 20 | this.socket.on(class="st">"message", (data, isBinary) => { |
| 21 | const message = isBinary ? data : data.toString(); |
| 22 | debug(class="st">'received "%s"', message); |
| 23 | super.onData(message); |
| 24 | }); |
| 25 | this.socket.once(class="st">"close", this.onClose.bind(this)); |
| 26 | this.socket.on(class="st">"error", this.onError.bind(this)); |
| 27 | this.writable = true; |
| 28 | this.perMessageDeflate = null; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Transport name |