networked-aframe / naf-janus-adapter

networked-aframe Janus network adapter
Mozilla Public License 2.0
12 stars 9 forks source link

State "naf:reconnecting" when connection is bad and it reconnects #67

Open vincentfretin opened 5 months ago

vincentfretin commented 5 months ago

I have the following code in my project that add a "naf:reconnecting" state I'm using to not show a user left message for clientDisconnected event and using it in video-texture-target and waypoint components as well to clean the projected screen share of the disconnected user or unoccupy waypoint if the user really disconnected and that's not just me that reconnects.

if (!NAF.adapters.adapters.janus.prototype.reconnectOriginal) {
    NAF.adapters.adapters.janus.prototype.reconnectOriginal = NAF.adapters.adapters.janus.prototype.reconnect;
    NAF.adapters.adapters.janus.prototype.reconnect = async function () {
      const sceneEl = document.querySelector("a-scene");
      if (!sceneEl) {
        return;
      }
      sceneEl.addState("naf:reconnecting");
      await this.reconnectOriginal();
      sceneEl.removeState("naf:reconnecting");
    };
  }

Properly add that in the adapter in next release.