diff --git a/dnssd.h b/dnssd.h index f3a3273..d484dd6 100644 --- a/dnssd.h +++ b/dnssd.h @@ -30,6 +30,7 @@ - (void)browse:(CDVInvokedUrlCommand*)command; - (void)resolve:(CDVInvokedUrlCommand*)command; +- (void)stopBrowsing:(CDVInvokedUrlCommand*)command; @end diff --git a/dnssd.js b/dnssd.js index 119c19e..0756beb 100644 --- a/dnssd.js +++ b/dnssd.js @@ -10,6 +10,11 @@ function DNSSD() { } +DNSSD.prototype.stopBrowsing = function(callback) { + console.log("Stop browsing."); + cordova.exec(callback, function(){}, "fi.peekpoke.cordova.dnssd", "stopBrowsing", []); +} + DNSSD.prototype.browse=function(regType, domain, serviceFound, serviceLost) { console.log("browse "+regType); diff --git a/dnssd.m b/dnssd.m index 1a8db8f..c94d92c 100644 --- a/dnssd.m +++ b/dnssd.m @@ -24,6 +24,18 @@ @implementation CDVBonjour #error This plugin requires ARC #endif +- (void)stopBrowsing:(CDVInvokedUrlCommand*)command +{ + [self.netServiceBrowser stop]; + self.netServiceBrowser = nil; + + [self.currentResolve stop]; + self.currentResolve = nil; + + CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; +} + //- (void)browse:(NSArray*)arguments withDict:(NSDictionary*)options - (void)browse:(CDVInvokedUrlCommand*)command {