-- Integration-test helper: connect to the mcp-bridge link server, send a hello -- frame, then reply to every `request` with a `pong` response until a deadline -- expires. Args (via shell.run): id, label, urlBase, durationSeconds. local args = {...}; local id = tonumber(args[1]) or 1; local label = args[2] or "echo"; local urlBase = args[3] or "ws://127.0.0.1:2001"; local duration = tonumber(args[4]) or 5; local url = urlBase .. "/?id=" .. id; local ws, err = http.websocket(url); if not ws then print("websocket failed: " .. tostring(err)); os.shutdown(); return; end ws.send(textutils.serializeJSON({ type = "hello", computerId = id, computerLabel = label, })); local deadline = os.epoch("utc") + duration * 1000; while os.epoch("utc") < deadline do local msg = ws.receive(0.5); if msg then local frame = textutils.unserializeJSON(msg); if frame and frame.type == "request" then ws.send(textutils.serializeJSON({ type = "response", id = frame.id, ok = true, result = "pong from " .. id .. " (Label: " .. label .. ")", })); end end end pcall(function() ws.close(); end); os.shutdown();