mirror of
https://github.com/rommapp/romm.git
synced 2026-12-04 21:02:21 +01:00
fix(streaming): enter a running game off the poll only on the claimed container
The status poll names no container, so it can answer with another tab's session on the same platform, and a loading tab that missed launch-ready would adopt that room as its own and later save and end it on unload.
This commit is contained in:
@@ -616,6 +616,25 @@ describe("Stream launch recovery", () => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it("keeps waiting when the poll finds a game on another container", async () => {
|
||||
// The unnamed poll reports any session the player holds on the platform,
|
||||
// which can be another tab's.
|
||||
const wrapper = await launch({ picker: false });
|
||||
await vmOf(wrapper).onPlay();
|
||||
mocks.fetchSessionStatus.mockResolvedValue({
|
||||
status: "active",
|
||||
platform: "gba",
|
||||
host: "http://webstation-dev-2:8080/room/y",
|
||||
container: "WEBSTATION-DEV-2",
|
||||
});
|
||||
|
||||
await pollStatus();
|
||||
|
||||
expect(vmOf(wrapper).playerState).toBe("loading");
|
||||
expect(vmOf(wrapper).containerHost).toBe("");
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it("keeps waiting while the launch has no room yet", async () => {
|
||||
const wrapper = await launch({ picker: false });
|
||||
await vmOf(wrapper).onPlay();
|
||||
|
||||
@@ -566,8 +566,9 @@ async function handleSessionStatus(
|
||||
// the room the launch recorded, which is the way back in.
|
||||
async function enterRunningSession(status: SessionStatus): Promise<void> {
|
||||
if (playerState.value !== "loading" || !status.host) return;
|
||||
// The 202 named it, except for a tab that came back without one.
|
||||
claimedContainer.value ??= status.container ?? null;
|
||||
// The poll names no container, so it can answer with another tab's session.
|
||||
if (!claimedContainer.value || status.container !== claimedContainer.value)
|
||||
return;
|
||||
launchPhase.value = null;
|
||||
containerHost.value = status.host;
|
||||
playerState.value = "playing";
|
||||
|
||||
Reference in New Issue
Block a user