Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions fleetmanager/gamelift_fleet_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
GameSessionDataKey = "GameSessionData"
GamePropertiesKey = "GameProperties"
GameSessionNameKey = "GameSessionName"
PlacementIdKey = "placementId"
)

const (
Expand Down Expand Up @@ -238,7 +239,7 @@ func (fm *GameLiftFleetManager) Create(ctx context.Context, maxPlayers int, user

var playerLatencies []types.PlayerLatency
if len(latencies) > 0 {
playerLatencies = make([]types.PlayerLatency, 0, len(playerLatencies))
playerLatencies = make([]types.PlayerLatency, 0, len(latencies))
for _, l := range latencies {
playerLatencies = append(playerLatencies, types.PlayerLatency{
LatencyInMilliseconds: aws.Float32(l.LatencyInMilliseconds),
Expand All @@ -248,7 +249,19 @@ func (fm *GameLiftFleetManager) Create(ctx context.Context, maxPlayers int, user
}
}

placementId := fm.callbackHandler.GenerateCallbackId()
var placementId string
if metadata != nil {
if v, ok := metadata[PlacementIdKey]; ok {
if s, ok := v.(string); ok && strings.TrimSpace(s) != "" {
placementId = s
fm.logger.WithField("placement_id", placementId).Debug("using placementId from metadata")
}
}
}
if placementId == "" {
placementId = fm.callbackHandler.GenerateCallbackId()
fm.logger.WithField("placement_id", placementId).Debug("no placementId in metadata; generated fallback")
}
fm.logger.WithField("placement_id", placementId).WithField("game_properties", gameProperties).Debug("placement input")

placementInput := &gamelift.StartGameSessionPlacementInput{
Expand Down Expand Up @@ -954,3 +967,7 @@ func InstanceIdToStorageKey(id string) (string, error) {

return tokens[len(tokens)-1], nil
}

func (fm *GameLiftFleetManager) GeneratePlacementId() string {
return fm.callbackHandler.GenerateCallbackId()
}
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ github.com/aws/smithy-go v1.19.0 h1:KWFKQV80DpP3vJrrA9sVAHQ5gc2z8i4EzrLhLlWXcBM=
github.com/aws/smithy-go v1.19.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/heroiclabs/nakama-common v1.33.0 h1:ojGPgVZ/goyAH6jrm3Emg7034yGDdqB/f5vTa6AJ5n0=
github.com/heroiclabs/nakama-common v1.33.0/go.mod h1:lPG64MVCs0/tEkh311Cd6oHX9NLx2vAPx7WW7QCJHQ0=
github.com/heroiclabs/nakama-common v1.36.0 h1:wg2sLnoJdh9r49Hhi0j0PIoCiVJfwAkwo8xjuHi75j8=
github.com/heroiclabs/nakama-common v1.36.0/go.mod h1:35jpsZHB/fxxD2YcfG35ZE6HhJlla8vBkHCkuJERXbs=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=