RemoteSystemSessionController Kelas

Definisi

Menangani pembuatan dan pengelolaan sesi jarak jauh baru untuk bergabung dengan perangkat lain.

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
Warisan
Object Platform::Object IInspectable RemoteSystemSessionController
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 Creators Update (diperkenalkan dalam 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v4.0)
Kemampuan aplikasi
remoteSystem

Contoh

Lihat kode berikut untuk contoh cara membuat sesi jarak jauh dan menangani permintaan gabungan.

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

Keterangan

Setiap sesi jarak jauh memiliki satu peserta yang merupakan pengontrol sesi. Hanya pengontrol yang dapat menentukan opsi untuk sesi, menerima permintaan bergabung dari peserta yang akan menjadi peserta, dan menghapus peserta dari sesi.

Penting

Anda harus mengonfirmasi akses ke platform sistem jarak jauh dengan panggilan ke RemoteSystem.RequestAccessAsync sebelum Anda membuat instans kelas ini.

Konstruktor

RemoteSystemSessionController(String)

Menginisialisasi RemoteSystemSessionController dengan nama tampilan kustom.

RemoteSystemSessionController(String, RemoteSystemSessionOptions)

Menginisialisasi RemoteSystemSessionController dengan nama tampilan kustom dan opsi yang ditentukan.

Metode

CreateSessionAsync()

Secara asinkron mencoba membuat sesi jarak jauh.

RemoveParticipantAsync(RemoteSystemSessionParticipant)

Menghapus peserta dari sesi jarak jauh.

Acara

JoinRequested

Dimunculkan setiap kali perangkat lain telah menemukan dan meminta akses ke sesi jarak jauh yang dikelola oleh RemoteSystemSessionController ini.

Berlaku untuk