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:
Hornwitser committed 2020-09-28 04:23:45 +02:00
1 parent f1f9b4d020
commit 392a7655c4
2 files changed
+4 -2

No files matched your search

+3 -1
View File
@@ -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]);
}
}
+1 -1
View File
@@ -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);