source: trip-planner-front/node_modules/multicast-dns/example.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 788 bytes
Line 
1var mdns = require('./')()
2
3mdns.on('warning', function (err) {
4 console.log(err.stack)
5})
6
7mdns.on('response', function (response) {
8 console.log('got a response packet:', response)
9})
10
11mdns.on('query', function (query) {
12 console.log('got a query packet:', query)
13
14 // iterate over all questions to check if we should respond
15 query.questions.forEach(function (q) {
16 if (q.type === 'A' && q.name === 'example.local') {
17 // send an A-record response for example.local
18 mdns.respond({
19 answers: [{
20 name: 'example.local',
21 type: 'A',
22 ttl: 300,
23 data: '192.168.1.5'
24 }]
25 })
26 }
27 })
28})
29
30// lets query for an A-record for example.local
31mdns.query({
32 questions: [{
33 name: 'example.local',
34 type: 'A'
35 }]
36})
Note: See TracBrowser for help on using the repository browser.