mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +09:00
Implement forwarding to instances for events
Implement forward to instance for Event messages.
This commit is contained in:
1 parent
e5115df28b
commit
513651393b
3 files changed
+49
-6
No files matched your search
@@ -297,6 +297,20 @@ class InstanceConnection extends link.Link {
|
||||
link.attachAllMessages(this);
|
||||
}
|
||||
|
||||
async forwardEventToInstance(message, event) {
|
||||
let instanceId = message.data.instance_id;
|
||||
if (!this.slave.instanceInfos.has(instanceId)) {
|
||||
// Instance is probably on another slave
|
||||
await this.slave.forwardEventToMaster(message, event);
|
||||
return;
|
||||
}
|
||||
|
||||
let instanceConnection = this.slave.instanceConnections.get(instanceId);
|
||||
if (!instanceConnection) { return; }
|
||||
|
||||
event.send(instanceConnection, message.data);
|
||||
}
|
||||
|
||||
async forwardEventToMaster(message, event) {
|
||||
event.send(this.slave, message.data);
|
||||
}
|
||||
@@ -388,6 +402,16 @@ class Slave extends link.Link {
|
||||
return await request.send(instanceConnection, message.data);
|
||||
}
|
||||
|
||||
async forwardEventToInstance(message, event) {
|
||||
let instanceId = message.data.instance_id;
|
||||
if (!this.instanceInfos.has(instanceId)) { return; }
|
||||
|
||||
let instanceConnection = this.instanceConnections.get(instanceId);
|
||||
if (!instanceConnection) { return; }
|
||||
|
||||
event.send(instanceConnection, message.data);
|
||||
}
|
||||
|
||||
async broadcastEventToInstance(message, event) {
|
||||
for (let instanceConnection of this.instanceConnections.values()) {
|
||||
event.send(instanceConnection, message.data);
|
||||
|
||||
Reference in new issue
Block a user