-api-id | -api-type |
---|---|
T:Windows.System.RemoteSystems.RemoteSystemSessionWatcher |
winrt class |
Watches for activity related to the discovery of remote sessions and raises the appropriate events.
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.
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();
}
remoteSystem