Fix incorrect device ID being set in Receiver API object

This commit is contained in:
hensm
2022-04-16 05:34:32 +01:00
parent 69ce675e0d
commit 2001a9481b
4 changed files with 24 additions and 21 deletions

View File

@@ -83,7 +83,9 @@ export default class Session extends CastClient {
volume: status.volume, volume: status.volume,
appId: application.appId, appId: application.appId,
displayName: application.displayName, displayName: application.displayName,
receiverFriendlyName: friendlyName, receiverId: this.receiverDevice.id,
receiverFriendlyName:
this.receiverDevice.friendlyName,
transportId: this.sessionId, transportId: this.sessionId,
// TODO: Fix this // TODO: Fix this
@@ -162,23 +164,25 @@ export default class Session extends CastClient {
) { ) {
super(); super();
super.connect(receiverDevice.host, { super
onHeartbeat: () => { .connect(receiverDevice.host, {
// Include transport heartbeat with platform heartbeat onHeartbeat: () => {
if (this.transportHeartbeat) { // Include transport heartbeat with platform heartbeat
this.transportHeartbeat.send({ type: "PING" }); if (this.transportHeartbeat) {
this.transportHeartbeat.send({ type: "PING" });
}
},
onReceiverMessage: message => {
this.onReceiverMessage(message);
} }
}, })
onReceiverMessage: message => { .then(() => {
this.onReceiverMessage(message); // Send a launch request and store the request ID for reference
} this.launchRequestId = this.sendReceiverMessage({
}).then(() => { type: "LAUNCH",
// Send a launch request and store the request ID for reference appId: this.appId
this.launchRequestId = this.sendReceiverMessage({ });
type: "LAUNCH",
appId: this.appId
}); });
});
// Handle client connection closed // Handle client connection closed
this.client.on("close", () => { this.client.on("close", () => {

View File

@@ -25,6 +25,7 @@ export interface CastSessionCreatedDetails extends CastSessionUpdatedDetails {
appId: string; appId: string;
appImages: Image[]; appImages: Image[];
displayName: string; displayName: string;
receiverId: string;
receiverFriendlyName: string; receiverFriendlyName: string;
senderApps: SenderApplication[]; senderApps: SenderApplication[];
transportId: string; transportId: string;

View File

@@ -5,10 +5,7 @@ import logger from "../../lib/logger";
import { ReceiverDevice } from "../../types"; import { ReceiverDevice } from "../../types";
import { ErrorCallback, SuccessCallback } from "../types"; import { ErrorCallback, SuccessCallback } from "../types";
import { import { onMessage, sendMessageResponse } from "../eventMessageChannel";
onMessage,
sendMessageResponse
} from "../eventMessageChannel";
import { import {
AutoJoinPolicy, AutoJoinPolicy,
@@ -262,7 +259,7 @@ onMessage(message => {
// TODO: Implement persistent per-origin receiver IDs // TODO: Implement persistent per-origin receiver IDs
const receiver = new Receiver( const receiver = new Receiver(
status.receiverFriendlyName, // label status.receiverId, // label
status.receiverFriendlyName, // friendlyName status.receiverFriendlyName, // friendlyName
[Capability.VIDEO_OUT, Capability.AUDIO_OUT], // capabilities [Capability.VIDEO_OUT, Capability.AUDIO_OUT], // capabilities
status.volume // volume status.volume // volume

View File

@@ -60,6 +60,7 @@ export interface CastSessionCreatedDetails extends CastSessionUpdatedDetails {
appId: string; appId: string;
appImages: Image[]; appImages: Image[];
displayName: string; displayName: string;
receiverId: string;
receiverFriendlyName: string; receiverFriendlyName: string;
senderApps: SenderApplication[]; senderApps: SenderApplication[];
transportId: string; transportId: string;