(type, data)
| 16167 | } |
| 16168 | } |
| 16169 | #onMessage(type, data) { |
| 16170 | if (this.#handler.readyState !== states.OPEN) { |
| 16171 | return; |
| 16172 | } |
| 16173 | let dataForEvent; |
| 16174 | if (type === opcodes.TEXT) { |
| 16175 | try { |
| 16176 | dataForEvent = utf8Decode(data); |
| 16177 | } catch { |
| 16178 | failWebsocketConnection(this.#handler, 1007, "Received invalid UTF-8 in text frame."); |
| 16179 | return; |
| 16180 | } |
| 16181 | } else if (type === opcodes.BINARY) { |
| 16182 | if (this.#binaryType === "blob") { |
| 16183 | dataForEvent = new Blob([data]); |
| 16184 | } else { |
| 16185 | dataForEvent = toArrayBuffer(data); |
| 16186 | } |
| 16187 | } |
| 16188 | fireEvent("message", this, createFastMessageEvent2, { |
| 16189 | origin: this.#url.origin, |
| 16190 | data: dataForEvent |
| 16191 | }); |
| 16192 | } |
| 16193 | #onParserDrain() { |
| 16194 | this.#handler.socket.resume(); |
| 16195 | } |
no test coverage detected