Delen via


ON_SESSION_CLOSED evenement (app-profielbeheer)

Deze gebeurtenis wordt door de client aangeroepen wanneer een sessie wordt afgesloten. Deze gebeurtenis biedt de mogelijkheid om opschoningstaken uit te voeren of de status van de toepassing bij te werken als reactie op het sluiten van de sessie. ON_SESSION_CLOSED gebeurtenis heeft de volgende eventData:

gebeurtenisgegevens Description
sessie-ID De sessie-ID van de sessie die dichtbij was.

Example


// Define a handler function that's triggered when a session is closed
let sessionClosedHandlerFunction = function(eventInput) {
    // Log the ID of the closed session to the console
    console.log("Session closed: " + eventInput.data.sessionId);
};
// Retrieve the event topic specific to session closing from the API
let sessionCloseTopic = Microsoft.Apm.getEventPublisherTopic("ON_SESSION_CLOSED");
// Create a new broadcast channel to subscribe to session close events
let sessionCloseSubscriber = new BroadcastChannel(sessionCloseTopic);
// Attach the session closed handler function to the message event of the subscriber
sessionCloseSubscriber.onmessage = sessionClosedHandlerFunction;

Opmerking

Het codevoorbeeld maakt gebruik van de Broadcast Channel API - Web API's om te communiceren tussen verschillende documenten, zoals pagina's of iframes die van dezelfde oorsprong zijn. Zorg ervoor dat het compatibel is met uw aanpassingen, aangezien de ondersteuning voor deze API kan variƫren.