File size: 797 Bytes
e239a9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const io = require('socket.io-client');
const socket = io('https://jatin25027-ros-simulation-dashboard.hf.space', { transports: ['websocket', 'polling'] });

socket.on('connect', () => {
    console.log('Connected to Hugging Face space!');
    socket.emit('build-and-run', 'ros_2');
});

socket.on('output', (data) => {
    console.log(`[OUTPUT] ${data.type}: ${data.message}`);
    if (data.message.includes('Enter choice')) {
        console.log('Sending choice 1');
        socket.emit('send-input', { projectId: 'ros_2', input: '1' });
    }
    if (data.message.includes('Enter number of robots')) {
        console.log('Sending 3 robots');
        socket.emit('send-input', { projectId: 'ros_2', input: '3' });
    }
});

socket.on('disconnect', () => {
    console.log('Disconnected');
});