MCPcopy Index your code
hub / github.com/nodejs/node / #onMessage

Method #onMessage

deps/undici/undici.js:16169–16192  ·  view source on GitHub ↗
(type, data)

Source from the content-addressed store, hash-verified

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 }

Callers 1

_WebSocketClass · 0.95

Calls 3

failWebsocketConnectionFunction · 0.70
toArrayBufferFunction · 0.70
fireEventFunction · 0.70

Tested by

no test coverage detected