createStreamSessionConnection method
Enables clients to reconnect to a stream session while preserving all
session state and data in the disconnected session. This reconnection
process can be initiated when a stream session is in either
PENDING_CLIENT_RECONNECTION or ACTIVE status.
The process works as follows:
-
Initial disconnect:
-
When a client disconnects or loses connection, the stream session
transitions from
CONNECTEDtoPENDING_CLIENT_RECONNECTION
-
When a client disconnects or loses connection, the stream session
transitions from
-
Reconnection time window:
-
Clients have
ConnectionTimeoutSeconds(defined in StartStreamSession) to reconnect before session termination - Your backend server must call CreateStreamSessionConnection to initiate reconnection
-
Session transitions to
RECONNECTINGstatus
-
Clients have
-
Reconnection completion:
-
On successful CreateStreamSessionConnection, session status changes
to
ACTIVE - Provide the new connection information to the requesting client
-
Client must establish connection within
ConnectionTimeoutSeconds - Session terminates automatically if client fails to connect in time
-
On successful CreateStreamSessionConnection, session status changes
to
To begin re-connecting to an existing stream session, specify the stream group ID and stream session ID that you want to reconnect to, and the signal request to use with the stream.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter identifier :
Amazon
Resource Name (ARN) or ID that uniquely identifies the stream group
resource. Example ARN:
arn:aws:gameliftstreams:us-west-2:111122223333:streamgroup/sg-1AB2C3De4.
Example ID: sg-1AB2C3De4.
The stream group that you want to run this stream session with. The stream
group must be in ACTIVE status.
Parameter signalRequest :
A WebRTC ICE offer string to use when initializing a WebRTC connection.
The offer is a very long JSON string. Provide the string as a text value
in quotes. The offer must be newly generated, not the same offer provided
to StartStreamSession.
Parameter streamSessionIdentifier :
Amazon
Resource Name (ARN) or ID that uniquely identifies the stream session
resource. Example ARN:
arn:aws:gameliftstreams:us-west-2:111122223333:streamsession/sg-1AB2C3De4/ABC123def4567.
Example ID: ABC123def4567.
The stream session must be in PENDING_CLIENT_RECONNECTION or
ACTIVE status.
Parameter clientToken :
A unique identifier that represents a client request. The request is
idempotent, which ensures that an API request completes only once. When
users send a request, Amazon GameLift Streams automatically populates this
field.
Implementation
Future<CreateStreamSessionConnectionOutput> createStreamSessionConnection({
required String identifier,
required String signalRequest,
required String streamSessionIdentifier,
String? clientToken,
}) async {
final $payload = <String, dynamic>{
'SignalRequest': signalRequest,
'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/streamgroups/${Uri.encodeComponent(identifier)}/streamsessions/${Uri.encodeComponent(streamSessionIdentifier)}/connections',
exceptionFnMap: _exceptionFns,
);
return CreateStreamSessionConnectionOutput.fromJson(response);
}