/AWS1/IF_GMZ=>STARTSTREAMSESSION()
¶
About StartStreamSession¶
This action initiates a new stream session and outputs connection information that clients can use to access the stream. A stream session refers to an instance of a stream that Amazon GameLift Streams transmits from the server to the end-user. A stream session runs on a compute resource that a stream group has allocated. The start stream session process works as follows:
-
Prerequisites:
-
You must have a stream group in
ACTIVE
state -
You must have idle or on-demand capacity in a stream group in the location you want to stream from
-
You must have at least one application associated to the stream group (use AssociateApplications if needed)
-
-
Start stream request:
-
Your backend server calls StartStreamSession to initiate connection
-
Amazon GameLift Streams creates the stream session resource, assigns an Amazon Resource Name (ARN) value, and begins searching for available stream capacity to run the stream
-
Session transitions to
ACTIVATING
status
-
-
Placement completion:
-
If Amazon GameLift Streams is successful in finding capacity for the stream, the stream session status changes to
ACTIVE
status and StartStreamSession returns stream connection information -
If Amazon GameLift Streams was not successful in finding capacity within the placement timeout period (defined according to the capacity type and platform type), the stream session status changes to
ERROR
status and StartStreamSession returns aStatusReason
ofplacementTimeout
-
-
Connection completion:
-
Provide the new connection information to the requesting client
-
Client must establish connection within
ConnectionTimeoutSeconds
(specified in StartStreamSession parameters) -
Session terminates automatically if client fails to connect in time
-
For more information about the stream session lifecycle, see Stream sessions in the Amazon GameLift Streams Developer Guide.
Timeouts to be aware of that affect a stream session:
-
Placement timeout: The amount of time that Amazon GameLift Streams has to find capacity for a stream request. Placement timeout varies based on the capacity type used to fulfill your stream request:
-
Always-on capacity: 75 seconds
-
On-demand capacity:
-
Linux/Proton runtimes: 90 seconds
-
Windows runtime: 10 minutes
-
-
-
Connection timeout: The amount of time that Amazon GameLift Streams waits for a client to connect to a stream session in
ACTIVE
status, or reconnect to a stream session inPENDING_CLIENT_RECONNECTION
status, the latter of which occurs when a client disconnects or loses connection from a stream session. If no client connects before the timeout, Amazon GameLift Streams terminates the stream session. This value is specified byConnectionTimeoutSeconds
in theStartStreamSession
parameters. -
Idle timeout: A stream session will be terminated if no user input has been received for 60 minutes.
-
Maximum session length: A stream session will be terminated after this amount of time has elapsed since it started, regardless of any existing client connections. This value is specified by
SessionLengthSeconds
in theStartStreamSession
parameters.
To start a new stream session, specify a stream group ID and application ID, along with the transport protocol and signal request to use with the stream session.
For stream groups that have multiple locations, provide a set of locations ordered by priority using a Locations
parameter. Amazon GameLift Streams will start a single stream session in the next available location. An application must be finished replicating to a remote location before the remote location can host a stream.
To reconnect to a stream session after a client disconnects or loses connection, use CreateStreamSessionConnection.
Method Signature¶
IMPORTING¶
Required arguments:¶
iv_identifier
TYPE /AWS1/GMZIDENTIFIER
/AWS1/GMZIDENTIFIER
¶
The stream group to run this stream session with.
This value is an 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
.
iv_protocol
TYPE /AWS1/GMZPROTOCOL
/AWS1/GMZPROTOCOL
¶
The data transport protocol to use for the stream session.
iv_signalrequest
TYPE /AWS1/GMZSIGNALREQUEST
/AWS1/GMZSIGNALREQUEST
¶
A WebRTC ICE offer string to use when initializing a WebRTC connection. Typically, the offer is a very long JSON string. Provide the string as a text value in quotes.
Amazon GameLift Streams also supports setting the field to "NO_CLIENT_CONNECTION". This will create a session without needing any browser request or Web SDK integration. The session starts up as usual and waits for a reconnection from a browser, which is accomplished using CreateStreamSessionConnection.
iv_applicationidentifier
TYPE /AWS1/GMZIDENTIFIER
/AWS1/GMZIDENTIFIER
¶
An Amazon Resource Name (ARN) or ID that uniquely identifies the application resource. Example ARN:
arn:aws:gameliftstreams:us-west-2:111122223333:application/a-9ZY8X7Wv6
. Example ID:a-9ZY8X7Wv6
.
Optional arguments:¶
iv_clienttoken
TYPE /AWS1/GMZCLIENTTOKEN
/AWS1/GMZCLIENTTOKEN
¶
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.
iv_description
TYPE /AWS1/GMZDESCRIPTION
/AWS1/GMZDESCRIPTION
¶
A human-readable label for the stream session. You can update this value later.
iv_userid
TYPE /AWS1/GMZUSERID
/AWS1/GMZUSERID
¶
An opaque, unique identifier for an end-user, defined by the developer.
it_locations
TYPE /AWS1/CL_GMZLOCATIONLIST_W=>TT_LOCATIONLIST
TT_LOCATIONLIST
¶
A list of locations, in order of priority, where you want Amazon GameLift Streams to start a stream from. For example,
us-east-1
. Amazon GameLift Streams selects the location with the next available capacity to start a single stream session in. If this value is empty, Amazon GameLift Streams attempts to start a stream session in the primary location.For a complete list of locations that Amazon GameLift Streams supports, refer to Regions, quotas, and limitations in the Amazon GameLift Streams Developer Guide.
iv_connectiontimeoutseconds
TYPE /AWS1/GMZCONNTIMEOUTSECONDS
/AWS1/GMZCONNTIMEOUTSECONDS
¶
Length of time (in seconds) that Amazon GameLift Streams should wait for a client to connect or reconnect to the stream session. Applies to both connection and reconnection scenarios. This time span starts when the stream session reaches
ACTIVE
state. If no client connects before the timeout, Amazon GameLift Streams terminates the stream session. Default value is 120.
iv_sessionlengthseconds
TYPE /AWS1/GMZSESSIONLENGTHSECONDS
/AWS1/GMZSESSIONLENGTHSECONDS
¶
The maximum duration of a session. Amazon GameLift Streams will automatically terminate a session after this amount of time has elapsed, regardless of any existing client connections. Default value is 43200 (12 hours).
it_additionallaunchargs
TYPE /AWS1/CL_GMZGAMELAUNCHARGLST_W=>TT_GAMELAUNCHARGLIST
TT_GAMELAUNCHARGLIST
¶
A list of CLI arguments that are sent to the streaming server when a stream session launches. You can use this to configure the application or stream session details. You can also provide custom arguments that Amazon GameLift Streams passes to your game client.
AdditionalEnvironmentVariables
andAdditionalLaunchArgs
have similar purposes.AdditionalEnvironmentVariables
passes data using environment variables; whileAdditionalLaunchArgs
passes data using command-line arguments.
it_addlenvironmentvariables
TYPE /AWS1/CL_GMZENVIRONMENTVARIA00=>TT_ENVIRONMENTVARIABLES
TT_ENVIRONMENTVARIABLES
¶
A set of options that you can use to control the stream session runtime environment, expressed as a set of key-value pairs. You can use this to configure the application or stream session details. You can also provide custom environment variables that Amazon GameLift Streams passes to your game client.
If you want to debug your application with environment variables, we recommend that you do so in a local environment outside of Amazon GameLift Streams. For more information, refer to the Compatibility Guidance in the troubleshooting section of the Developer Guide.
AdditionalEnvironmentVariables
andAdditionalLaunchArgs
have similar purposes.AdditionalEnvironmentVariables
passes data using environment variables; whileAdditionalLaunchArgs
passes data using command-line arguments.
RETURNING¶
oo_output
TYPE REF TO /aws1/cl_gmzstartstreamsessout
/AWS1/CL_GMZSTARTSTREAMSESSOUT
¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->/aws1/if_gmz~startstreamsession(
it_additionallaunchargs = VALUE /aws1/cl_gmzgamelauncharglst_w=>tt_gamelauncharglist(
( new /aws1/cl_gmzgamelauncharglst_w( |string| ) )
)
it_addlenvironmentvariables = VALUE /aws1/cl_gmzenvironmentvaria00=>tt_environmentvariables(
(
VALUE /aws1/cl_gmzenvironmentvaria00=>ts_environmentvariables_maprow(
key = |string|
value = new /aws1/cl_gmzenvironmentvaria00( |string| )
)
)
)
it_locations = VALUE /aws1/cl_gmzlocationlist_w=>tt_locationlist(
( new /aws1/cl_gmzlocationlist_w( |string| ) )
)
iv_applicationidentifier = |string|
iv_clienttoken = |string|
iv_connectiontimeoutseconds = 123
iv_description = |string|
iv_identifier = |string|
iv_protocol = |string|
iv_sessionlengthseconds = 123
iv_signalrequest = |string|
iv_userid = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_arn = lo_result->get_arn( ).
lv_description = lo_result->get_description( ).
lv_id = lo_result->get_streamgroupid( ).
lv_userid = lo_result->get_userid( ).
lv_streamsessionstatus = lo_result->get_status( ).
lv_streamsessionstatusreas = lo_result->get_statusreason( ).
lv_protocol = lo_result->get_protocol( ).
lv_locationname = lo_result->get_location( ).
lv_signalrequest = lo_result->get_signalrequest( ).
lv_signalresponse = lo_result->get_signalresponse( ).
lv_connectiontimeoutsecond = lo_result->get_connectiontimeoutseconds( ).
lv_sessionlengthseconds = lo_result->get_sessionlengthseconds( ).
LOOP AT lo_result->get_additionallaunchargs( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lv_string = lo_row_1->get_value( ).
ENDIF.
ENDLOOP.
LOOP AT lo_result->get_addlenvironmentvariables( ) into ls_row_2.
lv_key = ls_row_2-key.
lo_value = ls_row_2-value.
IF lo_value IS NOT INITIAL.
lv_string = lo_value->get_value( ).
ENDIF.
ENDLOOP.
lv_filelocationuri = lo_result->get_logfilelocationuri( ).
lv_websdkprotocolurl = lo_result->get_websdkprotocolurl( ).
lv_timestamp = lo_result->get_lastupdatedat( ).
lv_timestamp = lo_result->get_createdat( ).
lv_arn = lo_result->get_applicationarn( ).
lo_exportfilesmetadata = lo_result->get_exportfilesmetadata( ).
IF lo_exportfilesmetadata IS NOT INITIAL.
lv_exportfilesstatus = lo_exportfilesmetadata->get_status( ).
lv_exportfilesreason = lo_exportfilesmetadata->get_statusreason( ).
lv_outputuri = lo_exportfilesmetadata->get_outputuri( ).
ENDIF.
ENDIF.