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.

Применяется к