33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
const { Observe, currentFacet, genUuid } = require("@syndicate-lang/core");
|
|
const S = activate require("@syndicate-lang/driver-streams-node");
|
|
const M = activate require("@syndicate-lang/driver-mdns");
|
|
|
|
spawn named 'test' {
|
|
const label = (new Date()).toJSON().replace(/\./g, '-');
|
|
// ^ I declare defeat. None of the underlying DNS and mDNS support
|
|
// libraries support fully-general DNS labels. In particular, labels
|
|
// with dots in them cause trouble. I tried to fix the underlying
|
|
// problem, but the changes required are just too much. So instead,
|
|
// I'm avoiding a perfectly reasonable use of DNS. This is why we
|
|
// can't have nice things.
|
|
const svc = M.Service(label, '_syndicate._tcp');
|
|
assert M.Publish(svc, null, 8001, {});
|
|
|
|
during M.Discovered(M.Service($name, '_syndicate._tcp'),
|
|
$hostName,
|
|
$port,
|
|
$txtDataRecords,
|
|
$address)
|
|
{
|
|
on start console.log('+', name, hostName, port, txtDataRecords, address);
|
|
on stop console.log('-', name, hostName, port, txtDataRecords, address);
|
|
}
|
|
|
|
during M.Discovered(M.Service($n, $t), $h, $p, $d, $a) {
|
|
if (t !== '_syndicate._tcp') {
|
|
on start console.log('**', t, n, h, p, d, a);
|
|
on stop console.log('==', t, n, h, p, d, a);
|
|
}
|
|
}
|
|
}
|