1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package gamelift 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/gamelift/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Reserves an open player slot in a game session for a player. New player sessions 15// can be created in any game session with an open slot that is in ACTIVE status 16// and has a player creation policy of ACCEPT_ALL. You can add a group of players 17// to a game session with CreatePlayerSessions. To create a player session, specify 18// a game session ID, player ID, and optionally a set of player data. If 19// successful, a slot is reserved in the game session for the player and a new 20// PlayerSession object is returned with a player session ID. The player references 21// the player session ID when sending a connection request to the game session, and 22// the game server can use it to validate the player reservation with the GameLift 23// service. Player sessions cannot be updated. Available in Amazon GameLift Local. 24// Related actions CreatePlayerSession | CreatePlayerSessions | 25// DescribePlayerSessions | StartGameSessionPlacement | 26// DescribeGameSessionPlacement | All APIs by task 27// (https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets) 28func (c *Client) CreatePlayerSession(ctx context.Context, params *CreatePlayerSessionInput, optFns ...func(*Options)) (*CreatePlayerSessionOutput, error) { 29 if params == nil { 30 params = &CreatePlayerSessionInput{} 31 } 32 33 result, metadata, err := c.invokeOperation(ctx, "CreatePlayerSession", params, optFns, addOperationCreatePlayerSessionMiddlewares) 34 if err != nil { 35 return nil, err 36 } 37 38 out := result.(*CreatePlayerSessionOutput) 39 out.ResultMetadata = metadata 40 return out, nil 41} 42 43// Represents the input for a request operation. 44type CreatePlayerSessionInput struct { 45 46 // A unique identifier for the game session to add a player to. 47 // 48 // This member is required. 49 GameSessionId *string 50 51 // A unique identifier for a player. Player IDs are developer-defined. 52 // 53 // This member is required. 54 PlayerId *string 55 56 // Developer-defined information related to a player. GameLift does not use this 57 // data, so it can be formatted as needed for use in the game. 58 PlayerData *string 59} 60 61// Represents the returned data in response to a request operation. 62type CreatePlayerSessionOutput struct { 63 64 // Object that describes the newly created player session record. 65 PlayerSession *types.PlayerSession 66 67 // Metadata pertaining to the operation's result. 68 ResultMetadata middleware.Metadata 69} 70 71func addOperationCreatePlayerSessionMiddlewares(stack *middleware.Stack, options Options) (err error) { 72 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreatePlayerSession{}, middleware.After) 73 if err != nil { 74 return err 75 } 76 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreatePlayerSession{}, middleware.After) 77 if err != nil { 78 return err 79 } 80 if err = addSetLoggerMiddleware(stack, options); err != nil { 81 return err 82 } 83 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 84 return err 85 } 86 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 87 return err 88 } 89 if err = addResolveEndpointMiddleware(stack, options); err != nil { 90 return err 91 } 92 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 93 return err 94 } 95 if err = addRetryMiddlewares(stack, options); err != nil { 96 return err 97 } 98 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 99 return err 100 } 101 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 102 return err 103 } 104 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 105 return err 106 } 107 if err = addClientUserAgent(stack); err != nil { 108 return err 109 } 110 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 111 return err 112 } 113 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addOpCreatePlayerSessionValidationMiddleware(stack); err != nil { 117 return err 118 } 119 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreatePlayerSession(options.Region), middleware.Before); err != nil { 120 return err 121 } 122 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 123 return err 124 } 125 if err = addResponseErrorMiddleware(stack); err != nil { 126 return err 127 } 128 if err = addRequestResponseLogging(stack, options); err != nil { 129 return err 130 } 131 return nil 132} 133 134func newServiceMetadataMiddleware_opCreatePlayerSession(region string) *awsmiddleware.RegisterServiceMetadata { 135 return &awsmiddleware.RegisterServiceMetadata{ 136 Region: region, 137 ServiceID: ServiceID, 138 SigningName: "gamelift", 139 OperationName: "CreatePlayerSession", 140 } 141} 142