Unity-Technologies / furioos-sdk-js

Furioos SDK for JavaScript
30 stars 14 forks source link

Issue with session resume #70

Open rvollebregt opened 1 year ago

rvollebregt commented 1 year ago

Hi Furioos Team,

We've implemented Furioos JS SDK within our product to stream our serious games. Currently we're running into an issue where the session resume is unreliable after a page refresh in a VueJS application.

Some of the times it works, and some of the times it doesn't. Whenever the Resume Session menu is shown (see screenshot) we don't receive theFS_SDK_EVENTS_NAME.ON_RESUME_SESSION event which in turn then triggers our start stream method which restarts the stream that was enabled before.

It somehow looks like the event is sometimes triggered before we can bind the event to a function. Even with a timeout of 10 seconds we don't receive the event anymore.

Our code currently looks like this:

      this.player = new Player(furioosLinkId, "furioos_container", {
        whiteLabel: true,
        hideTitle: true,
        hideToolbar: false,
        hidePlayButton: true,
        debugAppMode: false,
        inactiveTimeout: 120000, // 2 minutes
      });

      const self = this;

      // Resume session when possible
      console.log("bind session resume event");
      this.player.on(
        FS_SDK_EVENTS_NAME.ON_RESUME_SESSION,
        function ({ canResumeSession }) {
          console.log("can resume session");
          self.canResumeSession = canResumeSession;
          if (canResumeSession) {
            self.player.resumeSession();
          }
        }
      );

      console.log("bind start game event");
      // Start game on load
      this.player.on(FS_SDK_EVENTS_NAME.LOAD, function () {
        setTimeout(() => {
          if (!self.canResumeSession) {
            console.log("can't resume session, player start");
            self.player.start();
          }
        }, 10000);
      });

Do you have some advice on the timing for resuming sessions? Thanks!

image