diff --git a/lib/core/topic.dart b/lib/core/topic.dart index 5791009..aa4d7d1 100644 --- a/lib/core/topic.dart +++ b/lib/core/topic.dart @@ -100,7 +100,7 @@ class Topic { if (subscribeId == null) { // Create the listenable broadcast subscription stream. subscription = ros.stream; - subscribeId = ros.requestSubscriber(name); + await safeSend(Request( op: 'subscribe', id: subscribeId, @@ -144,11 +144,11 @@ class Topic { Future publish(dynamic message) async { // Advertise the topic and then send the publish request. await advertise(); - publishId = ros.requestPublisher(name); await safeSend(publishReq(message)); } Request publishReq(dynamic message) { + publishId = ros.requestPublisher(name); return Request( op: 'publish', topic: name, @@ -162,7 +162,6 @@ class Topic { Future advertise() async { if (!isAdvertised) { // Send the advertisement request. - advertiseId = ros.requestAdvertiser(name); await safeSend(advertiseReq()); // If the ROS connection closes show that we're not advertising anymore. watchForClose(); @@ -170,6 +169,7 @@ class Topic { } Request advertiseReq() { + advertiseId = ros.requestAdvertiser(name); return Request( op: 'advertise', id: advertiseId,