ON_SESSION_SWITCH udalosť (správca profilov aplikácie)

Túto udalosť vyvolá klient, keď sa relácia prepne na inú reláciu. Táto udalosť umožňuje obslužným programom na strane klienta reagovať na prepínače relácií a podľa potreby aktualizovať používateľské rozhranie alebo interný stav. ON_SESSION_SWITCH udalosť preberá nasledujúce eventData:

eventData Popis
previousSessionId ID relácie predchádzajúcej relácie.
newSessionId ID relácie, ktorá je teraz zameraná.

Príklad


// Define a handler function that's triggered when the session is switched
let sessionSwitchedHandlerFunction = function(eventInput) {
    // Log the previous and new session IDs to the console
    console.log("Previous session:  " + eventInput.data.previousSessionId +
                " - Current session: " + eventInput.data.newSessionId);

}; 
// Retrieve the event topic specific to session switching from the API
let sessionSwitchTopic = Microsoft.Apm.getEventPublisherTopic("ON_SESSION_SWITCH");
// Create a new broadcast channel to subscribe to session switch events
let sessionSwitchSubscriber = new BroadcastChannel(sessionSwitchTopic);
// Attach the session switched handler function to the message event of the subscriber
sessionSwitchSubscriber.onmessage = sessionSwitchedHandlerFunction;

Poznámka

Ukážka kódu využíva rozhranie API kanála vysielania – webové rozhrania API na komunikáciu medzi rôznymi dokumentmi, ako sú stránky alebo prvky iframe, ktoré sú rovnakého pôvodu. Uistite sa, že je kompatibilný s vaším prispôsobením, pretože podpora tohto rozhrania API sa môže líšiť.