RemoteSystemSession Class

Definition

Represents and handles a remote session that can be shared between two or more connected devices. See Remarks for information on this feature.

public ref class RemoteSystemSession sealed : IClosable
class RemoteSystemSession sealed : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Static(typeof(Windows.System.RemoteSystems.IRemoteSystemSessionStatics), 262144, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class RemoteSystemSession : System.IDisposable
Public NotInheritable Class RemoteSystemSession
Implements IDisposable
Inheritance
RemoteSystemSession
Attributes
Implements

Windows 10 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 joining a remote session (including obtaining a reference to a RemoteSystemSession instance).

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

Alternatively, see the following code for an example of how to create a remote session and handle join requests.

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

Remarks

Remote System Sessions is a part of the broader Remote Systems feature set. It allows an app to establish a session object as an intermediate third party that two or more devices can continually communicate through, enabling a number of new cross-device scenarios such as remote app messaging.

A session that has been joined is represented by a RemoteSystemSession object. A session that is known about but has not been joined is represented by a RemoteSystemSessionInfo object.

Properties

ControllerDisplayName

Gets the machine name of the device that is the controller of this remote session.

DisplayName

Gets the public-facing name for this remote session, given by the controller of the session.

Id

Gets the unique identifier for this remote session.

Methods

Close()

Closes the session, disconnecting all participants.

CreateParticipantWatcher()

Initializes a RemoteSystemSessionParticipantWatcher to monitor the participants of this remote session.

CreateWatcher()

Initializes and returns a RemoteSystemSessionWatcher object to monitor the presence of remote sessions.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

SendInvitationAsync(RemoteSystem)

Invites a given remote device to join this remote session.

Events

Disconnected

Raised when this device has been disconnected from this remote session.

Applies to