mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
Use property for calculating handler name
Replace usage of .constructor.name with a separate property to avoid issue with JavaScript terser mangling the class name during minification for the web build.
This commit is contained in:
1 parent
f1f9b4d020
commit
392a7655c4
2 files changed
+4
-2
No files matched your search
@@ -66,6 +66,7 @@ class Request extends Message {
|
||||
this.links = links;
|
||||
this.permission = permission || null;
|
||||
this.forwardTo = forwardTo;
|
||||
this.handlerSuffix = "RequestHandler";
|
||||
|
||||
this.requestType = type + "_request";
|
||||
this.responseType = type + "_response";
|
||||
@@ -681,6 +682,7 @@ class Event extends Message {
|
||||
this.links = links;
|
||||
this.forwardTo = forwardTo;
|
||||
this.broadcastTo = broadcastTo;
|
||||
this.handlerSuffix = "EventHandler";
|
||||
|
||||
if (forwardTo === "instance") {
|
||||
eventProperties = {
|
||||
@@ -956,7 +958,7 @@ messages.playerEvent = new Event({
|
||||
*/
|
||||
function attachAllMessages(link) {
|
||||
for (let [name, message] of Object.entries(messages)) {
|
||||
message.attach(link, link[name + message.constructor.name + "Handler"]);
|
||||
message.attach(link, link[name + message.handlerSuffix]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -433,7 +433,7 @@ function attachPluginMessages(link, pluginInfo, plugin) {
|
||||
throw new Error(`Type of ${name} message must start with "${pluginInfo.name}:"`);
|
||||
}
|
||||
|
||||
let handler = name + messageFormat.constructor.name + "Handler";
|
||||
let handler = name + messageFormat.handlerSuffix;
|
||||
if (plugin === null || !plugin[handler]) {
|
||||
messageFormat.attach(link);
|
||||
|
||||
|
||||
Reference in new issue
Block a user