RemoteSystemSession クラス

定義

接続されている 2 つ以上のデバイス間で共有できるリモート セッションを表し、処理します。 この機能の詳細については、「解説」を参照してください。

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
継承
Object Platform::Object IInspectable RemoteSystemSession
属性
実装

Windows の要件

デバイス ファミリ
Windows 10 Creators Update (10.0.15063.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v4.0 で導入)
アプリの機能
remoteSystem

リモート セッションに参加するプロセス ( 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
    }
}

または、リモート セッションを作成して参加要求を処理する方法の例については、次のコードを参照してください。

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

注釈

リモート システム セッションは、より広範なリモート システム機能セットの一部です。 これにより、アプリは、2 つ以上のデバイスが継続的に通信できる中間サード パーティとしてセッション オブジェクトを確立し、リモート アプリ メッセージングなどの多くの新しいクロスデバイス シナリオを可能にします。

参加しているセッションは、 RemoteSystemSession オブジェクトによって表されます。 既知のセッションが参加していないセッションは、 RemoteSystemSessionInfo オブジェクトによって表されます。

プロパティ

ControllerDisplayName

このリモート セッションのコントローラーであるデバイスのコンピューター名を取得します。

DisplayName

セッションのコントローラーによって指定された、このリモート セッションの公開名を取得します。

Id

このリモート セッションの一意識別子を取得します。

メソッド

Close()

セッションを閉じ、すべての参加者を切断します。

CreateParticipantWatcher()

RemoteSystemSessionParticipantWatcher を初期化して、このリモート セッションの参加者を監視します。

CreateWatcher()

RemoteSystemSessionWatcher オブジェクトを初期化して返し、リモート セッションの存在を監視します。

Dispose()

アンマネージ リソースの解放またはリセットに関連付けられているアプリケーション定義のタスクを実行します。

SendInvitationAsync(RemoteSystem)

特定のリモート デバイスをこのリモート セッションに参加するよう招待します。

イベント

Disconnected

このデバイスがこのリモート セッションから切断されたときに発生します。

適用対象