Update mind_server.js

This commit is contained in:
uukelele-scratch 2025-01-21 21:47:05 +00:00 committed by GitHub
parent 7b5e9d7045
commit 3eeb88e60e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -114,6 +114,18 @@ export function createMindServer(port = 8080) {
process.exit(0);
});
socket.on('send-message', (agentName, message) => {
if (!inGameAgents[agentName]) {
console.warn(`Agent ${agentName} not logged in, cannot send message via MindServer.`);
return
}
try {
console.log(`Sending message to agent ${agentName}: ${message}`);
inGameAgents[agentName].emit('send-message', agentName, message)
} catch (error) {
console.error('Error: ', error);
}
});
});
server.listen(port, 'localhost', () => {