RemoteSystemSessionWatcher Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Watches for activity related to the discovery of remote sessions and raises the appropriate events.
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
- Inheritance
- Attributes
Windows requirements
Device family |
Windows 10 Creators Update (introduced in 10.0.15063.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v4.0)
|
App capabilities |
remoteSystem
|
Examples
See the code example below for the process of discovering a remote session.
// 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();
}
Remarks
This class is instantiated when the RemoteSystemSession.CreateWatcher method is called.
Important
You must confirm access to the remote system platform with a call to RemoteSystem.RequestAccessAsync before you instantiate this class.
Important
The following conditions must be met in order for remote session discovery to work as intended:
- Bluetooth must be turned on for both the client and host devices. Session discovery may work via LAN discovery, but it isn’t guaranteed (it depends on the network configuration).
- In the Settings app on the host device, the Share across devices setting under System -> Shared Experiences must be set to "Everyone nearby".
- Client and host apps must have the same PackageFamilyName.
Properties
Status |
Gets the operational status of this remote session watcher. |
Methods
Start() |
Starts watching for discoverable remote sessions. The discovery process runs until the Stop method is called. A RemoteSystemSessionWatcher object can have its Start method called again at a later time. |
Stop() |
Stops watching for discoverable remote sessions. |
Events
Added |
Raised when a new remote session has been discovered by the RemoteSystemSessionWatcher. |
Removed |
Raised when a previously discovered remote session has disappeared. |
Updated |
Raised when a previously discovered remote session has some part of its information updated. |