RemoteSystemSessionWatcher クラス

定義

リモート セッションの検出に関連するアクティビティを監視し、適切なイベントを発生させます。

public ref class RemoteSystemSessionWatcher sealed
/// [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 RemoteSystemSessionWatcher final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class RemoteSystemSessionWatcher final
[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 RemoteSystemSessionWatcher
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class RemoteSystemSessionWatcher
Public NotInheritable Class RemoteSystemSessionWatcher
継承
Object Platform::Object IInspectable RemoteSystemSessionWatcher
属性

Windows の要件

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

リモート セッションを検出するプロセスについては、以下のコード例を参照してください。

// Discover an existing shared experience.
public void DiscoverExistingSessions() {

    // create a watcher for remote system sessions
    RemoteSystemSessionWatcher sessionWatcher = RemoteSystemSession.CreateWatcher();

    // register a handler for the "added" event
    sessionWatcher.Added += async (sender, args) => {

        // get a reference to the info about the discovered session
        RemoteSystemSessionInfo sessionInfo = args.RemoteSystemSessionInfo;

        // update the UI with the sessionInfo.DisplayName and 
        // sessionInfo.ControllerDisplayName strings. Save a reference to 
        // this RemoteSystemSessionInfo, to use when the user selects
        // this session from the UI

        //...
    };

    // Begin watching
    sessionWatcher.Start();
}

注釈

このクラスは、 RemoteSystemSession.CreateWatcher メソッドが呼び出されたときにインスタンス化されます。

重要

このクラスをインスタンス化する前に、 RemoteSystem.RequestAccessAsync を呼び出してリモート システム プラットフォームへのアクセスを確認する必要があります。

重要

リモート セッション検出が意図したとおりに機能するためには、次の条件を満たす必要があります。

  1. クライアント デバイスとホスト デバイスの両方で Bluetooth をオンにする必要があります。 セッション検出は LAN 検出を介して機能する可能性がありますが、保証されません (ネットワーク構成によって異なります)。
  2. ホスト デバイスの [設定] アプリで、[システム -> 共有エクスペリエンス] の [デバイス間で共有] 設定を [近くにいるすべてのユーザー] に設定する必要があります。
  3. クライアント アプリとホスト アプリには、同じ PackageFamilyName が必要です。

プロパティ

Status

このリモート セッション ウォッチャーの操作状態を取得します。

メソッド

Start()

検出可能なリモート セッションの監視を開始します。 検出プロセスは 、Stop メソッドが呼び出されるまで実行されます。 RemoteSystemSessionWatcher オブジェクトは、その Start メソッドを後で再度呼び出すことができます。

Stop()

検出可能なリモート セッションの監視を停止します。

イベント

Added

RemoteSystemSessionWatcher によって新しいリモート セッションが検出されたときに発生します。

Removed

以前に検出されたリモート セッションが消えたときに発生します。

Updated

以前に検出されたリモート セッションの情報の一部が更新されたときに発生します。

適用対象