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 管理的远程会话时引发。

适用于