mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 1000676 - Post: Expose SimpleServiceDiscovery.EVENT* constants. r=mfinkle
This commit is contained in:
parent
2712067761
commit
988a51c8dc
@ -11,9 +11,8 @@ Cu.import("resource://gre/modules/Services.jsm"); /*global Services */
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm"); /*global SimpleServiceDiscovery */
|
||||
|
||||
// TODO: Export these from SimpleServiceDiscovery.
|
||||
const EVENT_SERVICE_FOUND = "ssdp-service-found";
|
||||
const EVENT_SERVICE_LOST = "ssdp-service-lost";
|
||||
const EVENT_SERVICE_FOUND = SimpleServiceDiscovery.EVENT_SERVICE_FOUND;
|
||||
const EVENT_SERVICE_LOST = SimpleServiceDiscovery.EVENT_SERVICE_LOST;
|
||||
|
||||
// We want to keep this page fresh while it is open, so we decrease
|
||||
// our time between searches when it is opened, and revert to the
|
||||
|
@ -37,11 +37,17 @@ const SSDP_DISCOVER_PACKET =
|
||||
|
||||
const SSDP_DISCOVER_TIMEOUT = 10000;
|
||||
|
||||
const EVENT_SERVICE_FOUND = "ssdp-service-found";
|
||||
const EVENT_SERVICE_LOST = "ssdp-service-lost";
|
||||
|
||||
/*
|
||||
* SimpleServiceDiscovery manages any discovered SSDP services. It uses a UDP
|
||||
* broadcast to locate available services on the local network.
|
||||
*/
|
||||
var SimpleServiceDiscovery = {
|
||||
get EVENT_SERVICE_FOUND() { return EVENT_SERVICE_FOUND; },
|
||||
get EVENT_SERVICE_LOST() { return EVENT_SERVICE_LOST; },
|
||||
|
||||
_targets: new Map(),
|
||||
_services: new Map(),
|
||||
_searchSocket: null,
|
||||
@ -210,7 +216,7 @@ var SimpleServiceDiscovery = {
|
||||
// Clean out any stale services
|
||||
for (let [key, service] of this._services) {
|
||||
if (service.lastPing != this._searchTimestamp) {
|
||||
Services.obs.notifyObservers(null, "ssdp-service-lost", service.location);
|
||||
Services.obs.notifyObservers(null, EVENT_SERVICE_LOST, service.location);
|
||||
this._services.delete(service.location);
|
||||
}
|
||||
}
|
||||
@ -273,7 +279,7 @@ var SimpleServiceDiscovery = {
|
||||
// Only add and notify if we don't already know about this service
|
||||
if (!this._services.has(aService.location)) {
|
||||
this._services.set(aService.location, aService);
|
||||
Services.obs.notifyObservers(null, "ssdp-service-found", aService.location);
|
||||
Services.obs.notifyObservers(null, EVENT_SERVICE_FOUND, aService.location);
|
||||
}
|
||||
|
||||
// Make sure we remember this service is not stale
|
||||
|
Loading…
Reference in New Issue
Block a user