All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.gamelift.model.GameSessionConnectionInfo Maven / Gradle / Ivy

/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.gamelift.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Connection information for the new game session that is created with matchmaking. (with StartMatchmaking). * Once a match is set, the FlexMatch engine places the match and creates a new game session for it. This information, * including the game session endpoint and player sessions for each player in the original matchmaking request, is added * to the MatchmakingTicket, which can be retrieved by calling DescribeMatchmaking. *

*/ @Generated("software.amazon.awssdk:codegen") public final class GameSessionConnectionInfo implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField GAME_SESSION_ARN_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(GameSessionConnectionInfo::gameSessionArn)).setter(setter(Builder::gameSessionArn)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GameSessionArn").build()).build(); private static final SdkField IP_ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(GameSessionConnectionInfo::ipAddress)).setter(setter(Builder::ipAddress)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IpAddress").build()).build(); private static final SdkField DNS_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(GameSessionConnectionInfo::dnsName)).setter(setter(Builder::dnsName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DnsName").build()).build(); private static final SdkField PORT_FIELD = SdkField. builder(MarshallingType.INTEGER) .getter(getter(GameSessionConnectionInfo::port)).setter(setter(Builder::port)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Port").build()).build(); private static final SdkField> MATCHED_PLAYER_SESSIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .getter(getter(GameSessionConnectionInfo::matchedPlayerSessions)) .setter(setter(Builder::matchedPlayerSessions)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchedPlayerSessions").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(MatchedPlayerSession::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(GAME_SESSION_ARN_FIELD, IP_ADDRESS_FIELD, DNS_NAME_FIELD, PORT_FIELD, MATCHED_PLAYER_SESSIONS_FIELD)); private static final long serialVersionUID = 1L; private final String gameSessionArn; private final String ipAddress; private final String dnsName; private final Integer port; private final List matchedPlayerSessions; private GameSessionConnectionInfo(BuilderImpl builder) { this.gameSessionArn = builder.gameSessionArn; this.ipAddress = builder.ipAddress; this.dnsName = builder.dnsName; this.port = builder.port; this.matchedPlayerSessions = builder.matchedPlayerSessions; } /** *

* Amazon Resource Name (ARN) that is assigned to a * game session and uniquely identifies it. *

* * @return Amazon Resource Name (ARN) that is * assigned to a game session and uniquely identifies it. */ public String gameSessionArn() { return gameSessionArn; } /** *

* IP address of the instance that is running the game session. When connecting to a Amazon GameLift game server, a * client needs to reference an IP address (or DNS name) and port number. *

* * @return IP address of the instance that is running the game session. When connecting to a Amazon GameLift game * server, a client needs to reference an IP address (or DNS name) and port number. */ public String ipAddress() { return ipAddress; } /** *

* DNS identifier assigned to the instance that is running the game session. Values have the following format: *

*
    *
  • *

    * TLS-enabled fleets: <unique identifier>.<region identifier>.amazongamelift.com. *

    *
  • *
  • *

    * Non-TLS-enabled fleets: ec2-<unique identifier>.compute.amazonaws.com. (See Amazon EC2 Instance IP Addressing.) *

    *
  • *
*

* When connecting to a game session that is running on a TLS-enabled fleet, you must use the DNS name, not the IP * address. *

* * @return DNS identifier assigned to the instance that is running the game session. Values have the following * format:

*
    *
  • *

    * TLS-enabled fleets: <unique identifier>.<region identifier>.amazongamelift.com. *

    *
  • *
  • *

    * Non-TLS-enabled fleets: ec2-<unique identifier>.compute.amazonaws.com. (See Amazon EC2 Instance IP Addressing.) *

    *
  • *
*

* When connecting to a game session that is running on a TLS-enabled fleet, you must use the DNS name, not * the IP address. */ public String dnsName() { return dnsName; } /** *

* Port number for the game session. To connect to a Amazon GameLift game server, an app needs both the IP address * and port number. *

* * @return Port number for the game session. To connect to a Amazon GameLift game server, an app needs both the IP * address and port number. */ public Integer port() { return port; } /** * Returns true if the MatchedPlayerSessions property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public boolean hasMatchedPlayerSessions() { return matchedPlayerSessions != null && !(matchedPlayerSessions instanceof SdkAutoConstructList); } /** *

* A collection of player session IDs, one for each player ID that was included in the original matchmaking request. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasMatchedPlayerSessions()} to see if a value was sent in this field. *

* * @return A collection of player session IDs, one for each player ID that was included in the original matchmaking * request. */ public List matchedPlayerSessions() { return matchedPlayerSessions; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(gameSessionArn()); hashCode = 31 * hashCode + Objects.hashCode(ipAddress()); hashCode = 31 * hashCode + Objects.hashCode(dnsName()); hashCode = 31 * hashCode + Objects.hashCode(port()); hashCode = 31 * hashCode + Objects.hashCode(matchedPlayerSessions()); return hashCode; } @Override public boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof GameSessionConnectionInfo)) { return false; } GameSessionConnectionInfo other = (GameSessionConnectionInfo) obj; return Objects.equals(gameSessionArn(), other.gameSessionArn()) && Objects.equals(ipAddress(), other.ipAddress()) && Objects.equals(dnsName(), other.dnsName()) && Objects.equals(port(), other.port()) && Objects.equals(matchedPlayerSessions(), other.matchedPlayerSessions()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public String toString() { return ToString.builder("GameSessionConnectionInfo").add("GameSessionArn", gameSessionArn()) .add("IpAddress", ipAddress()).add("DnsName", dnsName()).add("Port", port()) .add("MatchedPlayerSessions", matchedPlayerSessions()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "GameSessionArn": return Optional.ofNullable(clazz.cast(gameSessionArn())); case "IpAddress": return Optional.ofNullable(clazz.cast(ipAddress())); case "DnsName": return Optional.ofNullable(clazz.cast(dnsName())); case "Port": return Optional.ofNullable(clazz.cast(port())); case "MatchedPlayerSessions": return Optional.ofNullable(clazz.cast(matchedPlayerSessions())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((GameSessionConnectionInfo) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Amazon Resource Name (ARN) that is assigned * to a game session and uniquely identifies it. *

* * @param gameSessionArn * Amazon Resource Name (ARN) that is * assigned to a game session and uniquely identifies it. * @return Returns a reference to this object so that method calls can be chained together. */ Builder gameSessionArn(String gameSessionArn); /** *

* IP address of the instance that is running the game session. When connecting to a Amazon GameLift game * server, a client needs to reference an IP address (or DNS name) and port number. *

* * @param ipAddress * IP address of the instance that is running the game session. When connecting to a Amazon GameLift game * server, a client needs to reference an IP address (or DNS name) and port number. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ipAddress(String ipAddress); /** *

* DNS identifier assigned to the instance that is running the game session. Values have the following format: *

*
    *
  • *

    * TLS-enabled fleets: <unique identifier>.<region identifier>.amazongamelift.com. *

    *
  • *
  • *

    * Non-TLS-enabled fleets: ec2-<unique identifier>.compute.amazonaws.com. (See Amazon EC2 Instance IP Addressing.) *

    *
  • *
*

* When connecting to a game session that is running on a TLS-enabled fleet, you must use the DNS name, not the * IP address. *

* * @param dnsName * DNS identifier assigned to the instance that is running the game session. Values have the following * format:

*
    *
  • *

    * TLS-enabled fleets: * <unique identifier>.<region identifier>.amazongamelift.com. *

    *
  • *
  • *

    * Non-TLS-enabled fleets: ec2-<unique identifier>.compute.amazonaws.com. (See Amazon EC2 Instance IP Addressing.) *

    *
  • *
*

* When connecting to a game session that is running on a TLS-enabled fleet, you must use the DNS name, * not the IP address. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dnsName(String dnsName); /** *

* Port number for the game session. To connect to a Amazon GameLift game server, an app needs both the IP * address and port number. *

* * @param port * Port number for the game session. To connect to a Amazon GameLift game server, an app needs both the * IP address and port number. * @return Returns a reference to this object so that method calls can be chained together. */ Builder port(Integer port); /** *

* A collection of player session IDs, one for each player ID that was included in the original matchmaking * request. *

* * @param matchedPlayerSessions * A collection of player session IDs, one for each player ID that was included in the original * matchmaking request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder matchedPlayerSessions(Collection matchedPlayerSessions); /** *

* A collection of player session IDs, one for each player ID that was included in the original matchmaking * request. *

* * @param matchedPlayerSessions * A collection of player session IDs, one for each player ID that was included in the original * matchmaking request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder matchedPlayerSessions(MatchedPlayerSession... matchedPlayerSessions); /** *

* A collection of player session IDs, one for each player ID that was included in the original matchmaking * request. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the * need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately * and its result is passed to {@link #matchedPlayerSessions(List)}. * * @param matchedPlayerSessions * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #matchedPlayerSessions(List) */ Builder matchedPlayerSessions(Consumer... matchedPlayerSessions); } static final class BuilderImpl implements Builder { private String gameSessionArn; private String ipAddress; private String dnsName; private Integer port; private List matchedPlayerSessions = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(GameSessionConnectionInfo model) { gameSessionArn(model.gameSessionArn); ipAddress(model.ipAddress); dnsName(model.dnsName); port(model.port); matchedPlayerSessions(model.matchedPlayerSessions); } public final String getGameSessionArn() { return gameSessionArn; } @Override public final Builder gameSessionArn(String gameSessionArn) { this.gameSessionArn = gameSessionArn; return this; } public final void setGameSessionArn(String gameSessionArn) { this.gameSessionArn = gameSessionArn; } public final String getIpAddress() { return ipAddress; } @Override public final Builder ipAddress(String ipAddress) { this.ipAddress = ipAddress; return this; } public final void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; } public final String getDnsName() { return dnsName; } @Override public final Builder dnsName(String dnsName) { this.dnsName = dnsName; return this; } public final void setDnsName(String dnsName) { this.dnsName = dnsName; } public final Integer getPort() { return port; } @Override public final Builder port(Integer port) { this.port = port; return this; } public final void setPort(Integer port) { this.port = port; } public final Collection getMatchedPlayerSessions() { return matchedPlayerSessions != null ? matchedPlayerSessions.stream().map(MatchedPlayerSession::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder matchedPlayerSessions(Collection matchedPlayerSessions) { this.matchedPlayerSessions = MatchedPlayerSessionListCopier.copy(matchedPlayerSessions); return this; } @Override @SafeVarargs public final Builder matchedPlayerSessions(MatchedPlayerSession... matchedPlayerSessions) { matchedPlayerSessions(Arrays.asList(matchedPlayerSessions)); return this; } @Override @SafeVarargs public final Builder matchedPlayerSessions(Consumer... matchedPlayerSessions) { matchedPlayerSessions(Stream.of(matchedPlayerSessions) .map(c -> MatchedPlayerSession.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final void setMatchedPlayerSessions(Collection matchedPlayerSessions) { this.matchedPlayerSessions = MatchedPlayerSessionListCopier.copyFromBuilder(matchedPlayerSessions); } @Override public GameSessionConnectionInfo build() { return new GameSessionConnectionInfo(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy