mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-22 06:02:07 +02:00
Update mind_server.js
This commit is contained in:
parent
7b5e9d7045
commit
3eeb88e60e
1 changed files with 13 additions and 1 deletions
|
@ -114,6 +114,18 @@ export function createMindServer(port = 8080) {
|
||||||
process.exit(0);
|
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', () => {
|
server.listen(port, 'localhost', () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue