RemoteSystemSessionController Classe

Définition

Gère la création et la gestion d’une nouvelle session à distance que d’autres appareils doivent rejoindre.

public ref class RemoteSystemSessionController sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.System.RemoteSystems.IRemoteSystemSessionControllerFactory, 262144, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class RemoteSystemSessionController final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.System.RemoteSystems.IRemoteSystemSessionControllerFactory), 262144, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class RemoteSystemSessionController
function RemoteSystemSessionController(displayName, options)
Public NotInheritable Class RemoteSystemSessionController
Héritage
Object Platform::Object IInspectable RemoteSystemSessionController
Attributs

Configuration requise pour Windows

Famille d’appareils
Windows 10 Creators Update (introduit dans 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduit dans v4.0)
Fonctionnalités de l’application
remoteSystem

Exemples

Consultez le code suivant pour obtenir un exemple de création d’une session à distance et de gestion des demandes de jointure.

public async void StartNewSharedExperience() {

    var manager = new RemoteSystemSessionController("Bob’s Minecraft game");

    // register the following code to handle the JoinRequested event
    manager.JoinRequested += async (sender, args) => {
        // Get the deferral
        var deferral = args.GetDeferral();

        // display the participant (args.JoinRequest.Participant) on UI, giving the 
        // user an opportunity to respond
        // ...

        // If the user chooses "accept", accept this remote system as a participant
        args.JoinRequest.Accept();
    };

    // create and start the session
    RemoteSystemSessionCreationResult createResult = await manager.CreateSessionAsync();

    // handle the creation result
    if (createResult.Status == RemoteSystemSessionCreationStatus.Success) {
        // creation was successful
        RemoteSystemSession currentSession = createResult.Session;

        // optionally subscribe to the disconnection event
        currentSession.Disconnected += async (sender, args) => {
            // update the UI, using args.Reason
            // ...
        };

        // Use session ...

    } else if (createResult.Status == RemoteSystemSessionCreationStatus.SessionLimitsExceeded) {
        // creation failed. Optionally update UI to indicate that there are too many sessions in progress
    } else {
        // creation failed for an unknown reason. Optionally update UI
    }
}

Remarques

Chaque session à distance a un participant qui est le contrôleur de la session. Seul le contrôleur peut spécifier des options pour la session, accepter les demandes de participation des participants et supprimer des participants de la session.

Important

Vous devez confirmer l’accès à la plateforme système distante avec un appel à RemoteSystem.RequestAccessAsync avant d’instancier cette classe.

Constructeurs

RemoteSystemSessionController(String)

Initialise un RemoteSystemSessionController avec un nom d’affichage personnalisé.

RemoteSystemSessionController(String, RemoteSystemSessionOptions)

Initialise un RemoteSystemSessionController avec un nom d’affichage personnalisé et des options spécifiées.

Méthodes

CreateSessionAsync()

Tente de manière asynchrone de créer une session distante.

RemoveParticipantAsync(RemoteSystemSessionParticipant)

Supprime un participant de la session à distance.

Événements

JoinRequested

Déclenché chaque fois qu’un autre appareil a découvert et demandé l’accès à la session distante gérée par ce RemoteSystemSessionController.

S’applique à