{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GameLift.Types.GameSessionConnectionInfo where

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

-- | Connection information for a new game session that is created in
-- response to a StartMatchmaking 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 MatchmakingTicket,
-- which can be retrieved by calling DescribeMatchmaking.
--
-- /See:/ 'newGameSessionConnectionInfo' smart constructor.
data GameSessionConnectionInfo = GameSessionConnectionInfo'
  { -- | 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 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 unique identifier for the game session. Use the game session ID.
    GameSessionConnectionInfo -> Maybe Text
gameSessionArn :: Prelude.Maybe Prelude.Text,
    -- | 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,
    -- | 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
(GameSessionConnectionInfo -> GameSessionConnectionInfo -> Bool)
-> (GameSessionConnectionInfo -> GameSessionConnectionInfo -> Bool)
-> Eq GameSessionConnectionInfo
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]
(Int -> ReadS GameSessionConnectionInfo)
-> ReadS [GameSessionConnectionInfo]
-> ReadPrec GameSessionConnectionInfo
-> ReadPrec [GameSessionConnectionInfo]
-> Read 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
(Int -> GameSessionConnectionInfo -> ShowS)
-> (GameSessionConnectionInfo -> String)
-> ([GameSessionConnectionInfo] -> ShowS)
-> Show GameSessionConnectionInfo
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.
 GameSessionConnectionInfo -> Rep GameSessionConnectionInfo x)
-> (forall x.
    Rep GameSessionConnectionInfo x -> GameSessionConnectionInfo)
-> Generic GameSessionConnectionInfo
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:
--
-- 'matchedPlayerSessions', 'gameSessionConnectionInfo_matchedPlayerSessions' - A collection of player session IDs, one for each player ID that was
-- included in the original matchmaking request.
--
-- '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.
--
-- 'gameSessionArn', 'gameSessionConnectionInfo_gameSessionArn' - A unique identifier for the game session. Use the game session ID.
--
-- '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.
--
-- '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' :: Maybe [MatchedPlayerSession]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> GameSessionConnectionInfo
GameSessionConnectionInfo'
    { $sel:matchedPlayerSessions:GameSessionConnectionInfo' :: Maybe [MatchedPlayerSession]
matchedPlayerSessions =
        Maybe [MatchedPlayerSession]
forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddress:GameSessionConnectionInfo' :: Maybe Text
ipAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:gameSessionArn:GameSessionConnectionInfo' :: Maybe Text
gameSessionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dnsName:GameSessionConnectionInfo' :: Maybe Text
dnsName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:port:GameSessionConnectionInfo' :: Maybe Natural
port = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe [MatchedPlayerSession] -> f (Maybe [MatchedPlayerSession]))
-> GameSessionConnectionInfo -> f GameSessionConnectionInfo
gameSessionConnectionInfo_matchedPlayerSessions = (GameSessionConnectionInfo -> Maybe [MatchedPlayerSession])
-> (GameSessionConnectionInfo
    -> Maybe [MatchedPlayerSession] -> GameSessionConnectionInfo)
-> Lens
     GameSessionConnectionInfo
     GameSessionConnectionInfo
     (Maybe [MatchedPlayerSession])
     (Maybe [MatchedPlayerSession])
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) ((Maybe [MatchedPlayerSession] -> f (Maybe [MatchedPlayerSession]))
 -> GameSessionConnectionInfo -> f GameSessionConnectionInfo)
-> ((Maybe [MatchedPlayerSession]
     -> f (Maybe [MatchedPlayerSession]))
    -> Maybe [MatchedPlayerSession]
    -> f (Maybe [MatchedPlayerSession]))
-> (Maybe [MatchedPlayerSession]
    -> f (Maybe [MatchedPlayerSession]))
-> GameSessionConnectionInfo
-> f GameSessionConnectionInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MatchedPlayerSession]
  [MatchedPlayerSession]
  [MatchedPlayerSession]
  [MatchedPlayerSession]
-> Iso
     (Maybe [MatchedPlayerSession])
     (Maybe [MatchedPlayerSession])
     (Maybe [MatchedPlayerSession])
     (Maybe [MatchedPlayerSession])
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 AnIso
  [MatchedPlayerSession]
  [MatchedPlayerSession]
  [MatchedPlayerSession]
  [MatchedPlayerSession]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> GameSessionConnectionInfo -> f GameSessionConnectionInfo
gameSessionConnectionInfo_ipAddress = (GameSessionConnectionInfo -> Maybe Text)
-> (GameSessionConnectionInfo
    -> Maybe Text -> GameSessionConnectionInfo)
-> Lens
     GameSessionConnectionInfo
     GameSessionConnectionInfo
     (Maybe Text)
     (Maybe Text)
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 unique identifier for the game session. Use the game session ID.
gameSessionConnectionInfo_gameSessionArn :: Lens.Lens' GameSessionConnectionInfo (Prelude.Maybe Prelude.Text)
gameSessionConnectionInfo_gameSessionArn :: (Maybe Text -> f (Maybe Text))
-> GameSessionConnectionInfo -> f GameSessionConnectionInfo
gameSessionConnectionInfo_gameSessionArn = (GameSessionConnectionInfo -> Maybe Text)
-> (GameSessionConnectionInfo
    -> Maybe Text -> GameSessionConnectionInfo)
-> Lens
     GameSessionConnectionInfo
     GameSessionConnectionInfo
     (Maybe Text)
     (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> GameSessionConnectionInfo -> f GameSessionConnectionInfo
gameSessionConnectionInfo_dnsName = (GameSessionConnectionInfo -> Maybe Text)
-> (GameSessionConnectionInfo
    -> Maybe Text -> GameSessionConnectionInfo)
-> Lens
     GameSessionConnectionInfo
     GameSessionConnectionInfo
     (Maybe Text)
     (Maybe Text)
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)

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

instance Prelude.Hashable GameSessionConnectionInfo

instance Prelude.NFData GameSessionConnectionInfo