deleted logs and WebRTC issue
Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
46
node.js
46
node.js
@@ -76,8 +76,6 @@ Config File Example:
|
||||
}
|
||||
}
|
||||
|
||||
console.log(chalk.green('🚀 Starting Ring Network Node...'));
|
||||
|
||||
const node = new RingNode(options);
|
||||
|
||||
// Handle graceful shutdown
|
||||
@@ -95,37 +93,30 @@ process.on('SIGTERM', async () => {
|
||||
|
||||
// Connect to bootstrap node if specified
|
||||
if (options.bootstrap) {
|
||||
console.log(chalk.cyan(`🔗 Connecting to bootstrap node: ${options.bootstrap}`));
|
||||
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const success = await node.joinRing(options.bootstrap);
|
||||
if (success) {
|
||||
console.log(chalk.green('✅ Successfully joined the ring network!'));
|
||||
} else {
|
||||
console.log(chalk.red('❌ Failed to join the ring network'));
|
||||
}
|
||||
await node.joinRing(options.bootstrap);
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Error joining network:'), error.message);
|
||||
// Connection failed
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// Set up event handlers for demonstration
|
||||
// Set up event handlers
|
||||
node.on('peerConnected', (peerId) => {
|
||||
console.log(chalk.blue(`👋 New peer connected: ${peerId.substring(0, 8)}`));
|
||||
// Peer connected
|
||||
});
|
||||
|
||||
node.on('peerDisconnected', (peerId) => {
|
||||
console.log(chalk.red(`👋 Peer disconnected: ${peerId.substring(0, 8)}`));
|
||||
// Peer disconnected
|
||||
});
|
||||
|
||||
node.on('ringMessage', ({ from, payload }) => {
|
||||
console.log(chalk.magenta(`📨 Ring message from ${from.substring(0, 8)}: ${JSON.stringify(payload)}`));
|
||||
// Ring message received
|
||||
});
|
||||
|
||||
node.on('networkUpdate', ({ from, payload }) => {
|
||||
console.log(chalk.cyan(`🔄 Network update from ${from.substring(0, 8)}`));
|
||||
// Network update received
|
||||
});
|
||||
|
||||
// Interactive commands
|
||||
@@ -146,7 +137,6 @@ function handleCommand(command) {
|
||||
if (args.length > 0) {
|
||||
const message = args.join(' ');
|
||||
node.sendRingMessage({ type: 'chat', content: message });
|
||||
console.log(chalk.green(`📤 Sent: ${message}`));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -164,12 +154,34 @@ function handleCommand(command) {
|
||||
});
|
||||
break;
|
||||
|
||||
case 'connections':
|
||||
const status = node.getConnectionStatus();
|
||||
const persistentConns = node.getPersistentConnections();
|
||||
|
||||
console.log(chalk.blue('\n🔗 Connection Status:'));
|
||||
console.log(` Total Connections: ${status.totalConnections}`);
|
||||
console.log(` Persistent Connections: ${status.persistentConnections}`);
|
||||
console.log(` Active Connections: ${status.activeConnections}`);
|
||||
console.log(` Known Nodes: ${status.knownNodes}`);
|
||||
console.log(` Oracle Nodes: ${status.oracleNodes}`);
|
||||
|
||||
if (persistentConns.length > 0) {
|
||||
console.log(chalk.blue('\n🔄 Persistent Connections:'));
|
||||
persistentConns.forEach(conn => {
|
||||
const timeSince = conn.lastSeen ? `${Math.floor((Date.now() - conn.lastSeen) / 1000)}s ago` : 'never';
|
||||
const statusColor = conn.connectionState === 'connected' ? chalk.green : chalk.red;
|
||||
console.log(` - ${conn.nodeId.substring(0, 8)}... [${statusColor(conn.connectionState)}] ${conn.isOracle ? '🔮' : '💾'} (${timeSince})`);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case 'help':
|
||||
console.log(chalk.blue(`
|
||||
📚 Available Commands:
|
||||
send <message> - Send a message through the ring
|
||||
info - Show network information
|
||||
peers - List connected peers
|
||||
connections - Show persistent connection status
|
||||
help - Show this help
|
||||
quit - Exit the node
|
||||
`));
|
||||
|
||||
Referencia en una nueva incidencia
Block a user