174174
175175<script lang="ts">
176176import {
177- Config , QueryTarget , Receiver , RecvErr , ReplyError , Sample , Session , Subscriber ,
177+ ChannelReceiver , Config , QueryTarget , Reply , ReplyError , Sample , Session , Subscriber ,
178178} from ' @eclipse-zenoh/zenoh-ts'
179179import axios from ' axios'
180180import { StatusCodes } from ' http-status-codes'
@@ -463,30 +463,23 @@ export default Vue.extend({
463463 }
464464
465465 try {
466- const receiver: void | Receiver = this .file_sync_session .get (topic , {
467- target: QueryTarget .BestMatching ,
466+ const receiver: ChannelReceiver < Reply > | undefined = await this .file_sync_session .get (topic , {
467+ target: QueryTarget .BEST_MATCHING ,
468468 })
469469
470- if (! ( receiver instanceof Receiver ) ) {
470+ if (! receiver ) {
471471 console .warn (` [CloudTrayMenu] Query for ${topic } returned void receiver. ` )
472472 return null
473473 }
474474
475- let reply = await receiver .receive ()
476- while (reply !== RecvErr .Disconnected ) {
477- if (reply === RecvErr .MalformedReply ) {
478- console .warn (` [CloudTrayMenu] Malformed reply while querying ${topic }. ` )
479- } else {
480- const response = reply .result ()
481- if (response instanceof Sample ) {
482- const payload = response .payload ().to_string ()
483- return this .parseFileSyncQueue (payload )
484- }
485- const errorResponse: ReplyError = response
486- console .warn (` [CloudTrayMenu] Query error for ${topic }: ` , errorResponse .payload ().to_string ())
475+ for await (const reply of receiver ) {
476+ const response = reply .result ()
477+ if (response instanceof Sample ) {
478+ const payload = response .payload ().toString ()
479+ return this .parseFileSyncQueue (payload )
487480 }
488-
489- reply = await receiver . receive ( )
481+ const errorResponse : ReplyError = response
482+ console . warn ( ` [CloudTrayMenu] Query error for ${ topic }: ` , errorResponse . payload (). toString () )
490483 }
491484 } catch (error ) {
492485 console .error (` [CloudTrayMenu] Failed to query ${topic }: ` , error )
@@ -534,7 +527,7 @@ export default Vue.extend({
534527 }
535528
536529 try {
537- this .uploading_subscriber = await this .file_sync_session .declare_subscriber (
530+ this .uploading_subscriber = await this .file_sync_session .declareSubscriber (
538531 MAJOR_TOM_FILE_SYNC_UPLOADING_TOPIC ,
539532 {
540533 handler : (sample : Sample ) => {
@@ -549,7 +542,7 @@ export default Vue.extend({
549542 },
550543 handleUploadingSample(sample : Sample ): void {
551544 try {
552- const payload = sample .payload ().to_string ()
545+ const payload = sample .payload ().toString ()
553546 const event = JSON .parse (payload ) as FileSyncUploadingEvent
554547 const transfer = this .normalizeUploadingEvent (event )
555548 if (! transfer ) {
0 commit comments