MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / sendControlSocketMessage

Function sendControlSocketMessage

packages/client/src/app/AppShell.tsx:2302–2327  ·  view source on GitHub ↗
(
    udid: string,
    encoded: string,
    dropIfBacklogged: boolean,
  )

Source from the content-addressed store, hash-verified

2300 }
2301
2302 function sendControlSocketMessage(
2303 udid: string,
2304 encoded: string,
2305 dropIfBacklogged: boolean,
2306 ): boolean {
2307 const state = ensureControlSocket(udid);
2308 if (state.socket.readyState === WebSocket.OPEN) {
2309 if (
2310 dropIfBacklogged &&
2311 state.socket.bufferedAmount > CONTROL_BACKLOG_DROP_BYTES
2312 ) {
2313 return true;
2314 }
2315 state.socket.send(encoded);
2316 } else {
2317 if (dropIfBacklogged) {
2318 const lastIndex = state.pending.length - 1;
2319 if (lastIndex >= 0 && state.pending[lastIndex].includes('"moved"')) {
2320 state.pending[lastIndex] = encoded;
2321 return true;
2322 }
2323 }
2324 state.pending.push(encoded);
2325 }
2326 return true;
2327 }
2328
2329 useEffect(() => {
2330 return () => {

Callers 1

sendControlNowFunction · 0.85

Calls 1

sendMethod · 0.65

Tested by

no test coverage detected