@litert/televoke
Version:
A simple RPC service framework.
63 lines • 2.18 kB
JavaScript
;
/**
* Copyright 2025 Angus.Fenying <fenying@litert.org>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createUnixSocketGateway = createUnixSocketGateway;
const LwDFX = require("@litert/lwdfx");
const node_events_1 = require("node:events");
const LwDFX_Transporter_1 = require("./LwDFX.Transporter");
class LwDfxUnixSocketGateway extends node_events_1.EventEmitter {
constructor(serverOpts, _gatewayOpts, _server) {
super();
this._gatewayOpts = _gatewayOpts;
this._server = _server;
this._gateway = null;
this._lwdfxServer = LwDFX.createServer({
...serverOpts,
alpWhitelist: ['televoke2']
});
this._lwdfxServer.on('connection', (conn) => {
this._server.registerChannel(new LwDFX_Transporter_1.LwDFXTransporter('lwdfx/unix', conn));
});
}
get running() {
return !!this._gateway;
}
async start() {
if (this._gateway) {
return;
}
this._gateway = LwDFX.UnixSocket.createGateway(this._lwdfxServer, this._gatewayOpts);
try {
await this._gateway.start();
}
catch (e) {
this._gateway = null;
throw e;
}
}
async stop() {
if (!this._gateway) {
return;
}
await this._gateway.stop();
this._gateway = null;
}
}
function createUnixSocketGateway(server, gatewayOpts, serverOpts = {}) {
return new LwDfxUnixSocketGateway(serverOpts, gatewayOpts, server);
}
//# sourceMappingURL=LwDFX.UnixSocket.Server.js.map