MCPcopy Create free account
hub / github.com/botbotrobotics/BotBrain / createTestConnection

Function createTestConnection

frontend/src/hooks/useRobotAvailability.ts:26–55  ·  view source on GitHub ↗
(address: string)

Source from the content-addressed store, hash-verified

24const DEFAULT_TIMEOUT = 2000;
25
26const createTestConnection = (address: string): ROSLIB.Ros => {
27 let cleanAddress = address.startsWith('@') ? address.substring(1) : address;
28 let url = cleanAddress;
29
30 if (!url.startsWith('ws://') && !url.startsWith('wss://') && !url.startsWith('http://') && !url.startsWith('https://')) {
31 url = `ws://${url}:9090`;
32 } else if (url.startsWith('http://')) {
33 url = url.replace('http://', 'ws://');
34 if (!url.includes(':')) {
35 url = `${url}:9090`;
36 }
37 } else if (url.startsWith('https://')) {
38 url = url.replace('https://', 'wss://');
39 if (!url.includes(':')) {
40 url = `${url}:9090`;
41 }
42 } else if ((url.startsWith('ws://') && !url.includes(':', 5)) ||
43 (url.startsWith('wss://') && !url.includes(':', 6))) {
44 url = `${url}:9090`;
45 }
46
47 const options: any = {
48 url,
49 transportLibrary: 'websocket',
50 groovyCompatibility: false,
51 encoding: 'cbor',
52 };
53
54 return new ROSLIB.Ros(options);
55};
56
57async function checkSingleRobot(
58 robot: Robot,

Callers 1

checkSingleRobotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected