Edit

Share via


MultiplayerService.TryWriteSessionByHandleAsync Method

Definition

Attempts to write a new or updated multiplayer session to the service, using the specified handle to the session.
A handle is a service-side pointer to a session. The handleid is a GUID identifier of the handle. Callers will usually get the handleid either from another player's MultiplayerActivityDetails, or from a protocol activation after a user has accepted an invite. The purpose of this method is to give the caller additional details on the failure or success.

This method returns a WriteSessionResult instead of throwing an exception, but only in cases where the write failed for a reason that is expected to occur during normal operation.

public Windows.Foundation.IAsyncOperation<Microsoft.Xbox.Services.Multiplayer.WriteSessionResult> TryWriteSessionByHandleAsync (Microsoft.Xbox.Services.Multiplayer.MultiplayerSession multiplayerSession, Microsoft.Xbox.Services.Multiplayer.MultiplayerSessionWriteMode multiplayerSessionWriteMode, string handleId);
abstract member TryWriteSessionByHandleAsync : Microsoft.Xbox.Services.Multiplayer.MultiplayerSession * Microsoft.Xbox.Services.Multiplayer.MultiplayerSessionWriteMode * string -> Windows.Foundation.IAsyncOperation<Microsoft.Xbox.Services.Multiplayer.WriteSessionResult>
override this.TryWriteSessionByHandleAsync : Microsoft.Xbox.Services.Multiplayer.MultiplayerSession * Microsoft.Xbox.Services.Multiplayer.MultiplayerSessionWriteMode * string -> Windows.Foundation.IAsyncOperation<Microsoft.Xbox.Services.Multiplayer.WriteSessionResult>

Parameters

multiplayerSession
MultiplayerSession

A MultiplayerSession object that has been modified with the changes to write.

multiplayerSessionWriteMode
MultiplayerSessionWriteMode

An enumeration value indicating the type of write operation.

handleId
String

Returns

Windows.Foundation.IAsyncOperation<WriteSessionResult>

Returns an IAsyncOperation<TResult> object that represents the state of the asynchronous operation. Completion of the asynchronous operation is signaled by using a handler that is passed to the IAsyncOperation<TResult>.Completed property. When the asynchronous operation is complete, the result of the operation can be retrieved by using the IAsyncOperation<TResult>.GetResults method.

The result is an object representing a WriteSessionResult object that contains the response returned from the server, a status with the result, as well as if the status was successful. The attributes in it may be different from the attributes in the passed in MultiplayerSessionRequest object.

Implements

Microsoft.Xbox.Services.Multiplayer.__IMultiplayerServicePublicNonVirtuals.TryWriteSessionByHandleAsync(Microsoft.Xbox.Services.Multiplayer.MultiplayerSession,Microsoft.Xbox.Services.Multiplayer.MultiplayerSessionWriteMode,System.String)

Remarks

Use this method only if your MultiplayerSession object doesn't have a MultiplayerSessionReference, as a handle's lifetime may be shorter than that of the session it points to.

If you leave a session that you are the last member of, and the sessionEmptyTimeout is equal to 0, then the session is deleted immediately and a nullptr is returned.

Calls V105 PUT /serviceconfigs/{serviceConfigurationId}/sessionTemplates/{sessiontemplateName}/sessions/{sessionName}

Applies to