RemoteSystemSessionController 類別

定義

處理新遠端會話的建立和管理,讓其他裝置加入。

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
繼承
Object Platform::Object IInspectable RemoteSystemSessionController
屬性

Windows 需求

裝置系列
Windows 10 Creators Update (已於 10.0.15063.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v4.0 引進)
應用程式功能
remoteSystem

範例

如需如何建立遠端會話及處理聯結要求的範例,請參閱下列程式碼。

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

備註

每個遠端會話都有一個參與者,該參與者是會話的控制器。 只有控制器可以指定會話的選項、接受來自會是參與者的聯結要求,以及從會話中移除參與者。

重要

您必須先使用呼叫 RemoteSystem.RequestAccessAsync 來確認遠端系統平臺的存取權,才能具現化此類別。

建構函式

RemoteSystemSessionController(String)

使用自訂顯示名稱初始化 RemoteSystemSessionController

RemoteSystemSessionController(String, RemoteSystemSessionOptions)

使用自訂顯示名稱和指定的選項,初始化 RemoteSystemSessionController

方法

CreateSessionAsync()

以非同步方式嘗試建立遠端會話。

RemoveParticipantAsync(RemoteSystemSessionParticipant)

從遠端會話中移除參與者。

事件

JoinRequested

每當另一部裝置探索並要求存取此 RemoteSystemSessionController所管理的遠端會話時引發。

適用於