RemoteSystemSessionInfo 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
包含遠端會話的識別資訊。
public ref class RemoteSystemSessionInfo 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 RemoteSystemSessionInfo final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class RemoteSystemSessionInfo 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 RemoteSystemSessionInfo
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class RemoteSystemSessionInfo
Public NotInheritable Class RemoteSystemSessionInfo
- 繼承
- 屬性
Windows 需求
裝置系列 |
Windows 10 Creators Update (已於 10.0.15063.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v4.0 引進)
|
應用程式功能 |
remoteSystem
|
範例
如需探索遠端會話的完整程式,請參閱下列程式碼範例 (,包括取得 RemoteSystemSessionInfo 實例的參考) 。
// 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();
}
一旦取得 RemoteSystemSessionInfo 參考之後,就可以用它來發出聯結要求。 如需加入遠端會話的程式,請參閱下列程式碼範例。
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
}
}
備註
已聯結的會話是由 RemoteSystemSession 物件表示。 已知但尚未聯結的會話是由 RemoteSystemSessionInfo 物件表示。
屬性
ControllerDisplayName |
取得電腦名稱稱,該裝置是遠端會話的控制器。 |
DisplayName |
取得遠端會話的公開名稱,由會話的控制器指定。 |
方法
JoinAsync() |
發出來自呼叫裝置的要求,以加入指定的遠端會話。 |