lisk-framework
Version:
Lisk blockchain application platform
37 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseChannel = void 0;
const constants_1 = require("../../constants");
class BaseChannel {
constructor(logger, namespace, events, endpoints) {
this._logger = logger;
this.namespace = namespace;
this.eventsList = events;
this.endpointHandlers = new Map();
this._requestId = 0;
for (const [methodName, handler] of endpoints) {
this.endpointHandlers.set(methodName, handler);
}
this.endpointsList = [...this.endpointHandlers.keys()];
}
isValidEventName(name, throwError = true) {
const result = constants_1.eventWithModuleNameReg.test(name);
if (throwError && !result) {
throw new Error(`[${this.namespace}] Invalid event name ${name}.`);
}
return result;
}
isValidActionName(name, throwError = true) {
const result = constants_1.eventWithModuleNameReg.test(name);
if (throwError && !result) {
throw new Error(`[${this.namespace}] Invalid action name ${name}.`);
}
return result;
}
_getNextRequestId() {
this._requestId += 1;
return this._requestId.toString();
}
}
exports.BaseChannel = BaseChannel;
//# sourceMappingURL=base_channel.js.map