cordova-plugin-sb-service-discovery
v1.1.1
Published
Simple plugin to get any SSDP / UPnP / DLNA service on a local network
Downloads
8
Maintainers
Readme
Cordova Service Discovery
Forked from: https://github.com/scottdermott/cordova-plugin-discovery
Simple plugin to get any SSDP / UPnP / DLNA service on a local network
Using
$ cordova plugin add cordova-plugin-sb-service-discovery
Example angular service to discover particle devices:
import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import 'rxjs/add/observable/fromPromise';
declare var serviceDiscovery: any;
@Injectable()
export class DiscoveryService {
constructor() {}
discoverParticleServices(): Observable<any[]> {
console.log('Start service discovery');
return Observable.fromPromise(
new Promise((resolve, reject) => {
try {
serviceDiscovery.getNetworkServices(
'ssdp:all',
function(devices) {
const particleDevices = devices.filter(d => {
const dString = JSON.stringify(d);
return dString.match('.*Particle.*');
});
console.log(JSON.stringify(particleDevices));
resolve(particleDevices);
},
function(err) {
console.log('ERROR:', err);
resolve([]);
}
);
} catch (err) {
console.log(err);
resolve([]);
}
})
);
}
}