-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfix-registration-timing.js
More file actions
38 lines (30 loc) · 1.23 KB
/
fix-registration-timing.js
File metadata and controls
38 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const fs = require('fs');
let content = fs.readFileSync('lib/central/central-connector.js', 'utf8');
// Find the open handler
const oldOpen = `this.ws.on('open', () => {
console.log('[Central] WebSocket opened, sending registration...');
console.log('[Central] Connected to central server');
this.connected = true;
this.reconnectAttempts = 0;
// Start heartbeat
this.startHeartbeat();
// Send initial registration
console.log('[Central] Registration message sent');
this.sendRegistration();
});`;
const newOpen = `this.ws.on('open', () => {
console.log('[Central] WebSocket opened, sending registration...');
console.log('[Central] Connected to central server');
this.connected = true;
this.reconnectAttempts = 0;
// Start heartbeat
this.startHeartbeat();
// Send initial registration (with small delay to ensure server is ready)
setTimeout(() => {
console.log('[Central] Registration message sent');
this.sendRegistration();
}, 100);
});`;
content = content.replace(oldOpen, newOpen);
fs.writeFileSync('lib/central/central-connector.js', content);
console.log('✓ Fixed registration timing');