{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.GameLift.Types.GameSessionConnectionInfo
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GameLift.Types.GameSessionConnectionInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GameLift.Types.MatchedPlayerSession
import qualified Amazonka.Prelude as Prelude

-- | Connection information for a new game session that is created in
-- response to a start matchmaking request. Once a match is made, the
-- FlexMatch engine 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 matchmaking ticket.
--
-- /See:/ 'newGameSessionConnectionInfo' smart constructor.
data GameSessionConnectionInfo = GameSessionConnectionInfo'
  { -- | The 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
    --     <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses 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.
    GameSessionConnectionInfo -> Maybe Text
dnsName :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the game session. Use the game session ID.
    GameSessionConnectionInfo -> Maybe Text
gameSessionArn :: Prelude.Maybe Prelude.Text,
    -- | The IP address of the game session. To connect to a GameLift game
    -- server, an app needs both the IP address and port number.
    GameSessionConnectionInfo -> Maybe Text
ipAddress :: Prelude.Maybe Prelude.Text,
    -- | A collection of player session IDs, one for each player ID that was
    -- included in the original matchmaking request.
    GameSessionConnectionInfo -> Maybe [MatchedPlayerSession]
matchedPlayerSessions :: Prelude.Maybe [MatchedPlayerSession],
    -- | The port number for the game session. To connect to a GameLift game
    -- server, an app needs both the IP address and port number.
    GameSessionConnectionInfo -> Maybe Natural
port :: Prelude.Maybe Prelude.Natural
  }
  deriving (GameSessionConnectionInfo -> GameSessionConnectionInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GameSessionConnectionInfo -> GameSessionConnectionInfo -> Bool
$c/= :: GameSessionConnectionInfo -> GameSessionConnectionInfo -> Bool
== :: GameSessionConnectionInfo -> GameSessionConnectionInfo -> Bool
$c== :: GameSessionConnectionInfo -> GameSessionConnectionInfo -> Bool
Prelude.Eq, ReadPrec [GameSessionConnectionInfo]
ReadPrec GameSessionConnectionInfo
Int -> ReadS GameSessionConnectionInfo
ReadS [GameSessionConnectionInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GameSessionConnectionInfo]
$creadListPrec :: ReadPrec [GameSessionConnectionInfo]
readPrec :: ReadPrec GameSessionConnectionInfo
$creadPrec :: ReadPrec GameSessionConnectionInfo
readList :: ReadS [GameSessionConnectionInfo]
$creadList :: ReadS [GameSessionConnectionInfo]
readsPrec :: Int -> ReadS GameSessionConnectionInfo
$creadsPrec :: Int -> ReadS GameSessionConnectionInfo
Prelude.Read, Int -> GameSessionConnectionInfo -> ShowS
[GameSessionConnectionInfo] -> ShowS
GameSessionConnectionInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GameSessionConnectionInfo] -> ShowS
$cshowList :: [GameSessionConnectionInfo] -> ShowS
show :: GameSessionConnectionInfo -> String
$cshow :: GameSessionConnectionInfo -> String
showsPrec :: Int -> GameSessionConnectionInfo -> ShowS
$cshowsPrec :: Int -> GameSessionConnectionInfo -> ShowS
Prelude.Show, forall x.
Rep GameSessionConnectionInfo x -> GameSessionConnectionInfo
forall x.
GameSessionConnectionInfo -> Rep GameSessionConnectionInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GameSessionConnectionInfo x -> GameSessionConnectionInfo
$cfrom :: forall x.
GameSessionConnectionInfo -> Rep GameSessionConnectionInfo x
Prelude.Generic)

-- |
-- Create a value of 'GameSessionConnectionInfo' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'dnsName', 'gameSessionConnectionInfo_dnsName' - The 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
--     <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses 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.
--
-- 'gameSessionArn', 'gameSessionConnectionInfo_gameSessionArn' - A unique identifier for the game session. Use the game session ID.
--
-- 'ipAddress', 'gameSessionConnectionInfo_ipAddress' - The IP address of the game session. To connect to a GameLift game
-- server, an app needs both the IP address and port number.
--
-- 'matchedPlayerSessions', 'gameSessionConnectionInfo_matchedPlayerSessions' - A collection of player session IDs, one for each player ID that was
-- included in the original matchmaking request.
--
-- 'port', 'gameSessionConnectionInfo_port' - The port number for the game session. To connect to a GameLift game
-- server, an app needs both the IP address and port number.
newGameSessionConnectionInfo ::
  GameSessionConnectionInfo
newGameSessionConnectionInfo :: GameSessionConnectionInfo
newGameSessionConnectionInfo =
  GameSessionConnectionInfo'
    { $sel:dnsName:GameSessionConnectionInfo' :: Maybe Text
dnsName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:gameSessionArn:GameSessionConnectionInfo' :: Maybe Text
gameSessionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddress:GameSessionConnectionInfo' :: Maybe Text
ipAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:matchedPlayerSessions:GameSessionConnectionInfo' :: Maybe [MatchedPlayerSession]
matchedPlayerSessions = forall a. Maybe a
Prelude.Nothing,
      $sel:port:GameSessionConnectionInfo' :: Maybe Natural
port = forall a. Maybe a
Prelude.Nothing
    }

-- | The 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
--     <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses 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.
gameSessionConnectionInfo_dnsName :: Lens.Lens' GameSessionConnectionInfo (Prelude.Maybe Prelude.Text)
gameSessionConnectionInfo_dnsName :: Lens' GameSessionConnectionInfo (Maybe Text)
gameSessionConnectionInfo_dnsName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameSessionConnectionInfo' {Maybe Text
dnsName :: Maybe Text
$sel:dnsName:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
dnsName} -> Maybe Text
dnsName) (\s :: GameSessionConnectionInfo
s@GameSessionConnectionInfo' {} Maybe Text
a -> GameSessionConnectionInfo
s {$sel:dnsName:GameSessionConnectionInfo' :: Maybe Text
dnsName = Maybe Text
a} :: GameSessionConnectionInfo)

-- | A unique identifier for the game session. Use the game session ID.
gameSessionConnectionInfo_gameSessionArn :: Lens.Lens' GameSessionConnectionInfo (Prelude.Maybe Prelude.Text)
gameSessionConnectionInfo_gameSessionArn :: Lens' GameSessionConnectionInfo (Maybe Text)
gameSessionConnectionInfo_gameSessionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameSessionConnectionInfo' {Maybe Text
gameSessionArn :: Maybe Text
$sel:gameSessionArn:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
gameSessionArn} -> Maybe Text
gameSessionArn) (\s :: GameSessionConnectionInfo
s@GameSessionConnectionInfo' {} Maybe Text
a -> GameSessionConnectionInfo
s {$sel:gameSessionArn:GameSessionConnectionInfo' :: Maybe Text
gameSessionArn = Maybe Text
a} :: GameSessionConnectionInfo)

-- | The IP address of the game session. To connect to a GameLift game
-- server, an app needs both the IP address and port number.
gameSessionConnectionInfo_ipAddress :: Lens.Lens' GameSessionConnectionInfo (Prelude.Maybe Prelude.Text)
gameSessionConnectionInfo_ipAddress :: Lens' GameSessionConnectionInfo (Maybe Text)
gameSessionConnectionInfo_ipAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameSessionConnectionInfo' {Maybe Text
ipAddress :: Maybe Text
$sel:ipAddress:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
ipAddress} -> Maybe Text
ipAddress) (\s :: GameSessionConnectionInfo
s@GameSessionConnectionInfo' {} Maybe Text
a -> GameSessionConnectionInfo
s {$sel:ipAddress:GameSessionConnectionInfo' :: Maybe Text
ipAddress = Maybe Text
a} :: GameSessionConnectionInfo)

-- | A collection of player session IDs, one for each player ID that was
-- included in the original matchmaking request.
gameSessionConnectionInfo_matchedPlayerSessions :: Lens.Lens' GameSessionConnectionInfo (Prelude.Maybe [MatchedPlayerSession])
gameSessionConnectionInfo_matchedPlayerSessions :: Lens' GameSessionConnectionInfo (Maybe [MatchedPlayerSession])
gameSessionConnectionInfo_matchedPlayerSessions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameSessionConnectionInfo' {Maybe [MatchedPlayerSession]
matchedPlayerSessions :: Maybe [MatchedPlayerSession]
$sel:matchedPlayerSessions:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe [MatchedPlayerSession]
matchedPlayerSessions} -> Maybe [MatchedPlayerSession]
matchedPlayerSessions) (\s :: GameSessionConnectionInfo
s@GameSessionConnectionInfo' {} Maybe [MatchedPlayerSession]
a -> GameSessionConnectionInfo
s {$sel:matchedPlayerSessions:GameSessionConnectionInfo' :: Maybe [MatchedPlayerSession]
matchedPlayerSessions = Maybe [MatchedPlayerSession]
a} :: GameSessionConnectionInfo) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The port number for the game session. To connect to a GameLift game
-- server, an app needs both the IP address and port number.
gameSessionConnectionInfo_port :: Lens.Lens' GameSessionConnectionInfo (Prelude.Maybe Prelude.Natural)
gameSessionConnectionInfo_port :: Lens' GameSessionConnectionInfo (Maybe Natural)
gameSessionConnectionInfo_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameSessionConnectionInfo' {Maybe Natural
port :: Maybe Natural
$sel:port:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Natural
port} -> Maybe Natural
port) (\s :: GameSessionConnectionInfo
s@GameSessionConnectionInfo' {} Maybe Natural
a -> GameSessionConnectionInfo
s {$sel:port:GameSessionConnectionInfo' :: Maybe Natural
port = Maybe Natural
a} :: GameSessionConnectionInfo)

instance Data.FromJSON GameSessionConnectionInfo where
  parseJSON :: Value -> Parser GameSessionConnectionInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GameSessionConnectionInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [MatchedPlayerSession]
-> Maybe Natural
-> GameSessionConnectionInfo
GameSessionConnectionInfo'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DnsName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"GameSessionArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IpAddress")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MatchedPlayerSessions"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Port")
      )

instance Prelude.Hashable GameSessionConnectionInfo where
  hashWithSalt :: Int -> GameSessionConnectionInfo -> Int
hashWithSalt Int
_salt GameSessionConnectionInfo' {Maybe Natural
Maybe [MatchedPlayerSession]
Maybe Text
port :: Maybe Natural
matchedPlayerSessions :: Maybe [MatchedPlayerSession]
ipAddress :: Maybe Text
gameSessionArn :: Maybe Text
dnsName :: Maybe Text
$sel:port:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Natural
$sel:matchedPlayerSessions:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe [MatchedPlayerSession]
$sel:ipAddress:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
$sel:gameSessionArn:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
$sel:dnsName:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dnsName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
gameSessionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ipAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MatchedPlayerSession]
matchedPlayerSessions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
port

instance Prelude.NFData GameSessionConnectionInfo where
  rnf :: GameSessionConnectionInfo -> ()
rnf GameSessionConnectionInfo' {Maybe Natural
Maybe [MatchedPlayerSession]
Maybe Text
port :: Maybe Natural
matchedPlayerSessions :: Maybe [MatchedPlayerSession]
ipAddress :: Maybe Text
gameSessionArn :: Maybe Text
dnsName :: Maybe Text
$sel:port:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Natural
$sel:matchedPlayerSessions:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe [MatchedPlayerSession]
$sel:ipAddress:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
$sel:gameSessionArn:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
$sel:dnsName:GameSessionConnectionInfo' :: GameSessionConnectionInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dnsName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
gameSessionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ipAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MatchedPlayerSession]
matchedPlayerSessions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
port