How to use the node-opcua-service-discovery._announceServerOnMulticastSubnet function in node-opcua-service-discovery

To help you get started, we’ve selected a few node-opcua-service-discovery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-server-discovery / src / opcua_discovery_server.js View on Github external
server.discoveryConfiguration = discoveryConfiguration;


        if (discoveryConfiguration) {

            const endpointUrl = serverInfo.discoveryUrls[0];
            const parsedUrl = url.parse(endpointUrl);

            const options ={
                applicationUri: serverInfo.applicationUri,
                port: parseInt(parsedUrl.port,10),
                path: parsedUrl.pathname || "/",
                capabilities: server.discoveryConfiguration.serverCapabilities || [ "DA" ]
            };
            // let's announce the server on the  mutlicast DNS
            server.bonjourEntry = _announceServerOnMulticastSubnet(discoveryServer.bonjour, options);
        }
        discoveryServer.registered_servers[key].serverInfo = serverInfo;

    } else {
        if (key in  discoveryServer.registered_servers) {
            const server  = discoveryServer.registered_servers[key];
            debugLog(chalk.cyan("unregistering server : "), server.serverUri.yellow);
            if (server.bonjourEntry) {
                server.bonjourEntry.stop();
                server.bonjourEntry = null;
            }
            delete  discoveryServer.registered_servers[key];
        }

    }