RemoteSystemSession Classe

Definizione

Rappresenta e gestisce una sessione remota che può essere condivisa tra due o più dispositivi connessi. Per informazioni su questa funzionalità, vedere Osservazioni.

public ref class RemoteSystemSession sealed : IClosable
/// [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 RemoteSystemSession final : IClosable
[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 RemoteSystemSession : System.IDisposable
Public NotInheritable Class RemoteSystemSession
Implements IDisposable
Ereditarietà
Object Platform::Object IInspectable RemoteSystemSession
Attributi
Implementazioni

Requisiti Windows

Famiglia di dispositivi
Windows 10 Creators Update (è stato introdotto in 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v4.0)
Funzionalità dell'app
remoteSystem

Esempio

Vedere l'esempio di codice seguente per il processo di aggiunta a una sessione remota (incluso il recupero di un riferimento a un'istanza di RemoteSystemSession ).

public async void JoinExistingSession() {

    // request to join. sessionInfo has already been selected by user.
    RemoteSystemSessionJoinResult joinResult = await sessionInfo.JoinAsync();

    // process the result
    if (joinResult.Status == RemoteSystemSessionJoinStatus.Success) {

        // if the join was successful, acquire a reference to the session
        currentSession = joinResult.Session;

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

        // update the UI with the session.DisplayName and 
        // session.ControllerDisplayName strings. Save a reference to 
        // this RemoteSystemSession, to use when the user selects
        // this session from the UI

    } else {
        // join request failed. optionally update UI
    }
}

In alternativa, vedere il codice seguente per un esempio di come creare una sessione remota e gestire le richieste di join.

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
    }
}

Commenti

Sessioni di sistema remoto fa parte del set di funzionalità sistemi remoti più ampio. Consente a un'app di stabilire un oggetto sessione come terze parti intermedie che due o più dispositivi possono comunicare continuamente, abilitando diversi nuovi scenari tra dispositivi, ad esempio la messaggistica remota dell'app.

Una sessione aggiunta è rappresentata da un oggetto RemoteSystemSession . Una sessione nota su ma non è stata aggiunta è rappresentata da un oggetto RemoteSystemSessionInfo .

Proprietà

ControllerDisplayName

Ottiene il nome del computer del dispositivo che è il controller di questa sessione remota.

DisplayName

Ottiene il nome pubblico per questa sessione remota, specificato dal controller della sessione.

Id

Ottiene l'identificatore univoco per questa sessione remota.

Metodi

Close()

Chiude la sessione, disconnettendo tutti i partecipanti.

CreateParticipantWatcher()

Inizializza un RemoteSystemSessionParticipantWatcher per monitorare i partecipanti di questa sessione remota.

CreateWatcher()

Inizializza e restituisce un oggetto RemoteSystemSessionWatcher per monitorare la presenza di sessioni remote.

Dispose()

Esegue attività definite dall'applicazione, come rilasciare o reimpostare risorse non gestite.

SendInvitationAsync(RemoteSystem)

Invita un determinato dispositivo remoto a partecipare a questa sessione remota.

Eventi

Disconnected

Generato quando questo dispositivo è stato disconnesso da questa sessione remota.

Si applica a