UNPKG

syslog-portal

Version:
27 lines 923 B
import { randomUUID } from 'node:crypto'; import { BaseServer } from './baseServer.js'; import { createSocket } from 'node:dgram'; export class UDPServer extends BaseServer { _server; _checkIn; async startListening() { this._server = createSocket({ type: 'udp4', }, (msg, rinfo) => { this.parseMessage(msg, rinfo); }); this._server.bind(this._port, '0.0.0.0'); this._log.info('Registering with watchdog'); this._entityId = randomUUID(); this._healthMonitor.register(this._entityId, 'UDPServer', 20000); this._checkIn = setInterval(this.pingMonitor.bind(this), 15000); } close() { this._server?.close(); if (this._checkIn) clearInterval(this._checkIn); this._healthMonitor.unregister(this._entityId); return Promise.resolve(); } } //# sourceMappingURL=udpServer.js.map