RemoteSystemSession RemoteSystemSession RemoteSystemSession 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 : sealed class RemoteSystemSession : IClosable, IRemoteSystemSessionpublic sealed class RemoteSystemSession : IDisposable, IRemoteSystemSessionPublic NotInheritable Class RemoteSystemSession Implements IDisposable, IRemoteSystemSession// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.RemoteSystemSession;

        // 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 == RemoteSystemSessionCreateStatus.Success) {
        // creation was successful
        RemoteSystemSession currentSession = createResult.RemoteSystemSession;

        // optionally subscribe to the disconnection event
        currentSession.Disconnected += async (sender, args) => {
            // update the UI, using args.Reason
            // ...
        };

        // Use session ...

    } else if (createResult.Status == RemoteSystemSessionCreateStatus.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 ControllerDisplayName ControllerDisplayName ControllerDisplayName

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

public : PlatForm::String ControllerDisplayName { get; }public string ControllerDisplayName { get; }Public ReadOnly Property ControllerDisplayName As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

The machine name of the controller device.

DisplayName DisplayName DisplayName DisplayName

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

public : PlatForm::String DisplayName { get; }public string DisplayName { get; }Public ReadOnly Property DisplayName As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

The display name for this session.

Id Id Id Id

Gets the unique identifier for this remote session.

public : PlatForm::String Id { get; }public string Id { get; }Public ReadOnly Property Id As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

An id string unique to this session.

Methods

Close() Close() Close() Close()

Closes the session, disconnecting all participants.

public : void Close()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.

CreateParticipantWatcher() CreateParticipantWatcher() CreateParticipantWatcher() CreateParticipantWatcher()

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

public : RemoteSystemSessionParticipantWatcher CreateParticipantWatcher()public RemoteSystemSessionParticipantWatcher CreateParticipantWatcher()Public Function CreateParticipantWatcher() As RemoteSystemSessionParticipantWatcher// You can use this method in JavaScript.
Returns

CreateWatcher() CreateWatcher() CreateWatcher() CreateWatcher()

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

public : static RemoteSystemSessionWatcher CreateWatcher()public static RemoteSystemSessionWatcher CreateWatcher()Public Static Function CreateWatcher() As RemoteSystemSessionWatcher// You can use this method in JavaScript.
Returns

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();
}

Dispose() Dispose() Dispose() Dispose()

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

This member is not implemented in C++void Dispose()Sub Disposevoid Dispose()

SendInvitationAsync(RemoteSystem) SendInvitationAsync(RemoteSystem) SendInvitationAsync(RemoteSystem) SendInvitationAsync(RemoteSystem)

Invites a given remote device to join this remote session.

public : IAsyncOperation<PlatForm::Boolean> SendInvitationAsync(RemoteSystem invitee)public IAsyncOperation<bool> SendInvitationAsync(RemoteSystem invitee)Public Function SendInvitationAsync(invitee As RemoteSystem) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
Parameters
invitee
RemoteSystem RemoteSystem RemoteSystem RemoteSystem

The RemoteSystem object representing the system to which this invitation is being sent.

Returns

An asynchronous operation with a boolean value: true if the invitation was sent successfully, otherwise false.

Remarks

The device receiving the invitation will need to use a RemoteSystemSessionInvitationListener to handle it.

Events

Disconnected Disconnected Disconnected Disconnected

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

public : event TypedEventHandler Disconnected<RemoteSystemSession,  RemoteSystemSessionDisconnectedEventArgs>public event TypedEventHandler Disconnected<RemoteSystemSession,  RemoteSystemSessionDisconnectedEventArgs>Public Event Disconnected<RemoteSystemSession,  RemoteSystemSessionDisconnectedEventArgs>// You can use this event in JavaScript.