Merge "SyncSlides: Only support one live presentation at a time."
diff --git a/dart/lib/discovery/client.dart b/dart/lib/discovery/client.dart
index 87b2d47..1274f86 100644
--- a/dart/lib/discovery/client.dart
+++ b/dart/lib/discovery/client.dart
@@ -49,8 +49,8 @@
serviceAttrs['deckid'] = presentation.deck.key;
serviceAttrs['name'] = presentation.deck.name;
serviceAttrs['thumbnailkey'] = presentation.deck.thumbnail.key;
+ serviceAttrs['presentationid'] = presentation.key;
v23discovery.Service serviceInfo = new v23discovery.Service()
- ..instanceId = presentation.key
..interfaceName = presentationInterfaceName
..instanceName = presentation.key
..attrs = serviceAttrs
@@ -63,7 +63,12 @@
_advertiseCalls[presentation.key] =
new ProxyResponseFuturePair(advertiser, advertiseResponseFuture);
- await advertiseResponseFuture;
+ v23discovery.AdvertiserAdvertiseResponseParams result =
+ await advertiseResponseFuture;
+ if (result.err != null) {
+ throw result.err;
+ }
+
log.info('Advertised ${presentation.deck.name} under ${presentation.key}.');
}
@@ -119,7 +124,10 @@
var scannerResponseFuture = scanner.ptr.scan(query, handlerStub);
_scanCall = new ProxyResponseFuturePair(scanner, scannerResponseFuture);
- await scannerResponseFuture;
+ v23discovery.ScannerScanResponseParams result = await scannerResponseFuture;
+ if (result.err != null) {
+ throw result.err;
+ }
log.info('Scan started.');
}
@@ -156,13 +164,15 @@
}
class ScanHandler extends v23discovery.ScanHandler {
+ Map<String, String> instanceIdToPresentationIdMap = new Map();
found(v23discovery.Service s) async {
- String key = s.instanceId;
+ String key = s.attrs['presentationid'];
+ instanceIdToPresentationIdMap[s.instanceId] = key;
log.info('Found presentation ${s.attrs['name']} under $key.');
// Ignore our own advertised services.
if (_advertiseCalls.containsKey(key)) {
log.info(
- 'Presentation ${s.attrs['name']} was advertised by this device itself, ignoring it.');
+ 'Presentation ${s.attrs['name']} was advertised by us; ignoring.');
return;
}
@@ -177,8 +187,11 @@
_onFoundEmitter.add(presentation);
}
- lost(String presentationId) {
- // Ignore our own advertised services.
+ lost(String instanceId) {
+ String presentationId = instanceIdToPresentationIdMap[instanceId];
+ if (presentationId == null) {
+ return;
+ }
log.info('Lost presentation $presentationId.');
_onLostEmitter.add(presentationId);
}
diff --git a/dart/pubspec.lock b/dart/pubspec.lock
index 8cef40f..af44d6f 100644
--- a/dart/pubspec.lock
+++ b/dart/pubspec.lock
@@ -238,7 +238,7 @@
syncbase:
description: syncbase
source: hosted
- version: "0.0.23"
+ version: "0.0.26"
test:
description: test
source: hosted
@@ -258,7 +258,7 @@
v23discovery:
description: v23discovery
source: hosted
- version: "0.0.7"
+ version: "0.0.8"
vector_math:
description: vector_math
source: hosted