RemoteSystemSession Kelas

Definisi

Mewakili dan menangani sesi jarak jauh yang dapat dibagikan antara dua atau beberapa perangkat yang terhubung. Lihat Keterangan untuk informasi tentang fitur ini.

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

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 contoh kode di bawah ini untuk proses bergabung dengan sesi jarak jauh (termasuk mendapatkan referensi ke instans 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
    }
}

Atau, 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

Sesi Sistem Jarak Jauh adalah bagian dari set fitur Sistem Jarak Jauh yang lebih luas. Ini memungkinkan aplikasi untuk membuat objek sesi sebagai pihak ketiga perantara yang dapat terus dikomunikasikan oleh dua perangkat atau lebih, memungkinkan sejumlah skenario lintas perangkat baru seperti olahpesan aplikasi jarak jauh.

Sesi yang telah bergabung diwakili oleh objek RemoteSystemSession . Sesi yang diketahui tetapi belum bergabung diwakili oleh objek RemoteSystemSessionInfo .

Properti

ControllerDisplayName

Mendapatkan nama mesin perangkat yang merupakan pengontrol sesi jarak jauh ini.

DisplayName

Mendapatkan nama publik untuk sesi jarak jauh ini, yang diberikan oleh pengontrol sesi.

Id

Mendapatkan pengidentifikasi unik untuk sesi jarak jauh ini.

Metode

Close()

Menutup sesi, memutuskan sambungan semua peserta.

CreateParticipantWatcher()

Menginisialisasi RemoteSystemSessionParticipantWatcher untuk memantau peserta sesi jarak jauh ini.

CreateWatcher()

Menginisialisasi dan mengembalikan objek RemoteSystemSessionWatcher untuk memantau keberadaan sesi jarak jauh.

Dispose()

Melakukan tugas yang ditentukan aplikasi yang terkait dengan membebaskan, melepaskan, atau mereset sumber daya yang tidak terkelola.

SendInvitationAsync(RemoteSystem)

Mengundang perangkat jarak jauh tertentu untuk bergabung dengan sesi jarak jauh ini.

Acara

Disconnected

Dimunculkan ketika perangkat ini telah terputus dari sesi jarak jauh ini.

Berlaku untuk