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

Method ping

deps/undici/undici.js:16233–16246  ·  view source on GitHub ↗

* @param {WebSocket} ws * @param {Buffer|undefined} buffer

(ws, buffer)

Source from the content-addressed store, hash-verified

16231 * @param {Buffer|undefined} buffer
16232 */
16233 static ping(ws, buffer) {
16234 if (Buffer.isBuffer(buffer)) {
16235 if (buffer.length > 125) {
16236 throw new TypeError("A PING frame cannot have a body larger than 125 bytes.");
16237 }
16238 } else if (buffer !== void 0) {
16239 throw new TypeError("Expected buffer payload");
16240 }
16241 const readyState = ws.#handler.readyState;
16242 if (isEstablished(readyState) && !isClosing(readyState) && !isClosed(readyState)) {
16243 const frame = new WebsocketFrameSend(buffer);
16244 ws.#handler.socket.write(frame.createFrame(opcodes.PING));
16245 }
16246 }
16247 };
16248 var { ping } = WebSocket;
16249 Reflect.deleteProperty(WebSocket, "ping");

Callers 8

test-http2-ping.jsFile · 0.45
test.jsFile · 0.45
ping.jsFile · 0.45
onHttp2SendPingFunction · 0.45

Calls 5

createFrameMethod · 0.95
isEstablishedFunction · 0.70
isClosingFunction · 0.70
isClosedFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected