MCPcopy
hub / github.com/audreyt/ethercalc / processInboundFrame

Function processInboundFrame

packages/socketio-shim/src/adapter.ts:188–209  ·  view source on GitHub ↗
(sid: string, raw: string)

Source from the content-addressed store, hash-verified

186 }
187
188 function processInboundFrame(sid: string, raw: string): void {
189 const packet = decodeFrame(raw);
190 if (!packet) return;
191 switch (packet.type) {
192 case PacketType.Disconnect:
193 closeSession(sid, 'client disconnected');
194 return;
195 case PacketType.Heartbeat:
196 // Clients echo the heartbeat; nothing to do — the fact that we
197 // received any frame already proves liveness.
198 return;
199 case PacketType.Event: {
200 const msg = socketIoEventToNative(packet);
201 if (msg) opts.onClientMessage(msg, sid);
202 return;
203 }
204 // Connect/Json/Message/Ack/Error/Noop: ignored. We only care about
205 // Event frames for the EtherCalc protocol.
206 default:
207 return;
208 }
209 }
210
211 function closeSession(sid: string, reason = 'closed'): void {
212 const session = sessions.get(sid);

Callers 2

acceptFunction · 0.85
handleXhrPollFunction · 0.85

Calls 3

decodeFrameFunction · 0.90
socketIoEventToNativeFunction · 0.90
closeSessionFunction · 0.85

Tested by

no test coverage detected