From 2001a9481bef7b4ecde1e842dc9b1882f574e3ea Mon Sep 17 00:00:00 2001 From: hensm Date: Sat, 16 Apr 2022 05:34:32 +0100 Subject: [PATCH] Fix incorrect device ID being set in Receiver API object --- app/src/bridge/components/cast/Session.ts | 36 +++++++++++++---------- app/src/bridge/types.ts | 1 + ext/src/cast/api/index.ts | 7 ++--- ext/src/cast/api/types.ts | 1 + 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/src/bridge/components/cast/Session.ts b/app/src/bridge/components/cast/Session.ts index faa6b4d..bdfc9c1 100644 --- a/app/src/bridge/components/cast/Session.ts +++ b/app/src/bridge/components/cast/Session.ts @@ -83,7 +83,9 @@ export default class Session extends CastClient { volume: status.volume, appId: application.appId, displayName: application.displayName, - receiverFriendlyName: friendlyName, + receiverId: this.receiverDevice.id, + receiverFriendlyName: + this.receiverDevice.friendlyName, transportId: this.sessionId, // TODO: Fix this @@ -162,23 +164,25 @@ export default class Session extends CastClient { ) { super(); - super.connect(receiverDevice.host, { - onHeartbeat: () => { - // Include transport heartbeat with platform heartbeat - if (this.transportHeartbeat) { - this.transportHeartbeat.send({ type: "PING" }); + super + .connect(receiverDevice.host, { + onHeartbeat: () => { + // Include transport heartbeat with platform heartbeat + if (this.transportHeartbeat) { + this.transportHeartbeat.send({ type: "PING" }); + } + }, + onReceiverMessage: message => { + this.onReceiverMessage(message); } - }, - onReceiverMessage: message => { - this.onReceiverMessage(message); - } - }).then(() => { - // Send a launch request and store the request ID for reference - this.launchRequestId = this.sendReceiverMessage({ - type: "LAUNCH", - appId: this.appId + }) + .then(() => { + // Send a launch request and store the request ID for reference + this.launchRequestId = this.sendReceiverMessage({ + type: "LAUNCH", + appId: this.appId + }); }); - }); // Handle client connection closed this.client.on("close", () => { diff --git a/app/src/bridge/types.ts b/app/src/bridge/types.ts index 26c8647..188e240 100644 --- a/app/src/bridge/types.ts +++ b/app/src/bridge/types.ts @@ -25,6 +25,7 @@ export interface CastSessionCreatedDetails extends CastSessionUpdatedDetails { appId: string; appImages: Image[]; displayName: string; + receiverId: string; receiverFriendlyName: string; senderApps: SenderApplication[]; transportId: string; diff --git a/ext/src/cast/api/index.ts b/ext/src/cast/api/index.ts index c09af75..0edaff9 100644 --- a/ext/src/cast/api/index.ts +++ b/ext/src/cast/api/index.ts @@ -5,10 +5,7 @@ import logger from "../../lib/logger"; import { ReceiverDevice } from "../../types"; import { ErrorCallback, SuccessCallback } from "../types"; -import { - onMessage, - sendMessageResponse -} from "../eventMessageChannel"; +import { onMessage, sendMessageResponse } from "../eventMessageChannel"; import { AutoJoinPolicy, @@ -262,7 +259,7 @@ onMessage(message => { // TODO: Implement persistent per-origin receiver IDs const receiver = new Receiver( - status.receiverFriendlyName, // label + status.receiverId, // label status.receiverFriendlyName, // friendlyName [Capability.VIDEO_OUT, Capability.AUDIO_OUT], // capabilities status.volume // volume diff --git a/ext/src/cast/api/types.ts b/ext/src/cast/api/types.ts index db8580b..85499c4 100644 --- a/ext/src/cast/api/types.ts +++ b/ext/src/cast/api/types.ts @@ -60,6 +60,7 @@ export interface CastSessionCreatedDetails extends CastSessionUpdatedDetails { appId: string; appImages: Image[]; displayName: string; + receiverId: string; receiverFriendlyName: string; senderApps: SenderApplication[]; transportId: string;