UNPKG

angular-ide

Version:

Provides a seamless integration with the Angular IDE from the command-line for developers looking for an enhanced development experience with Angular.

23 lines (19 loc) 938 B
function broadcastAliveMessage(udpServer, broadcastConfig, aliveMessageData) { const message = JSON.stringify(aliveMessageData); try { var buf = Buffer.from(message); udpServer.send(buf, 0, buf.length, broadcastConfig.port, broadcastConfig.host); } catch (e) { //for compatibility with Node.js 4.x and older udpServer.send(message, 0, message.length, broadcastConfig.port, broadcastConfig.host); } } function startBroadcastingAliveMessage(udpServer, broadcastConfig, aliveMessageData) { // Broadcast first message immediately broadcastAliveMessage(udpServer, broadcastConfig, aliveMessageData); // Broadcasting alive message every 3 secs time setInterval(() => broadcastAliveMessage(udpServer, broadcastConfig, aliveMessageData), broadcastConfig.interval); } module.exports.broadcastAliveMessage = broadcastAliveMessage; module.exports.startBroadcastingAliveMessage = startBroadcastingAliveMessage;