Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformatting example with some color.
- Loading branch information
1 parent
f1bc5f8
commit 930b150
Showing
1 changed file
with
15 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
var upnp = require('../lib/upnp'); | ||
var util = require('util'); | ||
var log = function(event) { | ||
return function(device) { | ||
console.log('UPNP Event %s: %s, %s', event, device.nt || device.st, device.usn); | ||
}; | ||
}; | ||
var upnp = require('../') | ||
, inspect = require('util').inspect | ||
, log = function(event) { | ||
return function(device) { | ||
console.log('UPNP Event: \033[33m%s\033[39m', event) | ||
console.log(inspect(device, true, 10, true)) | ||
console.log() | ||
} | ||
} | ||
|
||
cp = new upnp.ControlPoint(); | ||
cp.on('DeviceAvailable', log('DeviceAvailable')); | ||
cp.on('DeviceUpdated', log('DeviceUpdated')); | ||
cp.on('DeviceUnavailable', log('DeviceUnavailable')); | ||
cp.on('DeviceFound', log('DeviceFound')); | ||
cp.search(); | ||
cp = new upnp.ControlPoint() | ||
cp.on('DeviceAvailable', log('DeviceAvailable')) | ||
cp.on('DeviceUpdated', log('DeviceUpdated')) | ||
cp.on('DeviceUnavailable', log('DeviceUnavailable')) | ||
cp.on('DeviceFound', log('DeviceFound')) | ||
cp.search() |