ON_SESSION_SWITCH eveniment (Manager profil aplicație)

Acest eveniment este invocat de client atunci când o sesiune este comutată la o altă sesiune. Acest eveniment permite handlerilor din partea clientului să reacționeze la comutatoarele de sesiune, actualizând interfața cu utilizatorul sau starea internă după cum este necesar. ON_SESSION_SWITCH eveniment ia următorul eventData:

date de eveniment Descriere
previousSessionId ID-ul sesiunii anterioare.
newSessionId ID-ul sesiunii care este acum focalizat.

Exemplu


// 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;

Notă

Eșantionul de cod utilizează API-ul Canal de difuzare - API-uri web, pentru a comunica între diferite documente, cum ar fi pagini sau iframe-uri care sunt de aceeași origine. Asigurați-vă că este compatibil cu personalizarea dvs., deoarece suportul pentru acest API poate varia.