MCPcopy Index your code
hub / github.com/nodejs/node / _WebSocket

Class _WebSocket

deps/undici/undici.js:15878–16247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15876 }
15877 __name(getSocketAddress, "getSocketAddress");
15878 var WebSocket = class _WebSocket extends EventTarget {
15879 static {
15880 __name(this, "WebSocket");
15881 }
15882 #events = {
15883 open: null,
15884 error: null,
15885 close: null,
15886 message: null
15887 };
15888 #bufferedAmount = 0;
15889 #protocol = "";
15890 #extensions = "";
15891 /** @type {SendQueue} */
15892 #sendQueue;
15893 /** @type {Handler} */
15894 #handler = {
15895 onConnectionEstablished: /* @__PURE__ */ __name((response, extensions) => this.#onConnectionEstablished(response, extensions), "onConnectionEstablished"),
15896 onMessage: /* @__PURE__ */ __name((opcode, data) => this.#onMessage(opcode, data), "onMessage"),
15897 onParserError: /* @__PURE__ */ __name((err) => failWebsocketConnection(this.#handler, null, err.message), "onParserError"),
15898 onParserDrain: /* @__PURE__ */ __name(() => this.#onParserDrain(), "onParserDrain"),
15899 onSocketData: /* @__PURE__ */ __name((chunk) => {
15900 if (!this.#parser.write(chunk)) {
15901 this.#handler.socket.pause();
15902 }
15903 }, "onSocketData"),
15904 onSocketError: /* @__PURE__ */ __name((err) => {
15905 this.#handler.readyState = states.CLOSING;
15906 if (channels.socketError.hasSubscribers) {
15907 channels.socketError.publish(err);
15908 }
15909 this.#handler.socket.destroy();
15910 }, "onSocketError"),
15911 onSocketClose: /* @__PURE__ */ __name(() => this.#onSocketClose(), "onSocketClose"),
15912 onPing: /* @__PURE__ */ __name((body) => {
15913 if (channels.ping.hasSubscribers) {
15914 channels.ping.publish({
15915 payload: body,
15916 websocket: this
15917 });
15918 }
15919 }, "onPing"),
15920 onPong: /* @__PURE__ */ __name((body) => {
15921 if (channels.pong.hasSubscribers) {
15922 channels.pong.publish({
15923 payload: body,
15924 websocket: this
15925 });
15926 }
15927 }, "onPong"),
15928 readyState: states.CONNECTING,
15929 socket: null,
15930 closeState: /* @__PURE__ */ new Set(),
15931 controller: null,
15932 wasEverConnected: false
15933 };
15934 #url;
15935 #binaryType;

Callers

nothing calls this directly

Calls 10

#onMessageMethod · 0.95
#onParserDrainMethod · 0.95
#onSocketCloseMethod · 0.95
__nameFunction · 0.85
failWebsocketConnectionFunction · 0.70
pauseMethod · 0.65
writeMethod · 0.45
publishMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected