MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / websocketMessageReceived

Function websocketMessageReceived

out/cli.cjs:63061–63084  ·  view source on GitHub ↗
(ws, type2, data)

Source from the content-addressed store, hash-verified

63059 }
63060 function isClosed(ws) {
63061 return ws[kReadyState] === states.CLOSED;
63062 }
63063 function fireEvent(e3, target, eventConstructor = Event, eventInitDict) {
63064 const event = new eventConstructor(e3, eventInitDict);
63065 target.dispatchEvent(event);
63066 }
63067 function websocketMessageReceived(ws, type2, data) {
63068 if (ws[kReadyState] !== states.OPEN) {
63069 return;
63070 }
63071 let dataForEvent;
63072 if (type2 === opcodes.TEXT) {
63073 try {
63074 dataForEvent = new TextDecoder("utf-8", { fatal: true }).decode(data);
63075 } catch {
63076 failWebsocketConnection(ws, "Received invalid UTF-8 in text frame.");
63077 return;
63078 }
63079 } else if (type2 === opcodes.BINARY) {
63080 if (ws[kBinaryType] === "blob") {
63081 dataForEvent = new Blob([data]);
63082 } else {
63083 dataForEvent = new Uint8Array(data).buffer;
63084 }
63085 }
63086 fireEvent("message", ws, MessageEvent, {
63087 origin: ws[kWebSocketURL].origin,

Callers 1

runMethod · 0.85

Calls 3

failWebsocketConnectionFunction · 0.85
fireEventFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…