public NetworkServer(GameLift gamelift) { this.gamelift = gamelift; //Start the TCP server int port = this.gamelift.listeningPort; Debug.Log("Starting server on port " + port); listener = new TcpListener(IPAddress.Any, this.gamelift.listeningPort); Debug.Log("Listening at: " + listener.LocalEndpoint.ToString()); listener.Start(); }
public GameLiftClient(GameLift _gl) { gl = _gl; playerId = Guid.NewGuid().ToString(); Credentials.Install(); CreateGameLiftClient(); // Use command line alias if possible, otherwise use default (hard coded alias) string[] args = System.Environment.GetCommandLineArgs(); for (int i = 0; i < args.Length - 1; i++) { if (args[i] != "--alias") { continue; } string pattern = @"alias-[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"; Match m = Regex.Match(args[i + 1], pattern); if (m.Success) { aliasId = m.Value; Debug.Log(":) ALIAS RECOGNIZED. Alias " + aliasId + " found on command line"); break; } } // verify alias exists if (aglc != null) { try { var dareq = new Amazon.GameLift.Model.DescribeAliasRequest(); dareq.AliasId = aliasId; Amazon.GameLift.Model.DescribeAliasResponse dares = aglc.DescribeAlias(dareq); Amazon.GameLift.Model.Alias alias = dares.Alias; Debug.Log((int)dares.HttpStatusCode + " ALIAS NAME: " + alias.Name + " (" + aliasId + ")"); if (alias.RoutingStrategy.Type == Amazon.GameLift.RoutingStrategyType.TERMINAL) { Debug.Log(" (TERMINAL ALIAS)"); } } catch (Exception e) { Debug.Log("AWS Credentials found but probably invalid. Check IAM permissions for the credentials."); Debug.Log(e.Message); } } }
public void Awake() { Debug.Log(":) GAMELOGIC AWAKE"); // prevent the game going to sleep when the window loses focus Application.runInBackground = true; // Get pointers to scripts on other objects GameObject gameliftObj = GameObject.Find("/GameLiftStatic"); Debug.Assert(gameliftObj != null); gamelift = gameliftObj.GetComponent <GameLift>(); if (gamelift == null) { Debug.Log(":| GAMELIFT CODE NOT AVAILABLE ON GAMELIFTSTATIC OBJECT - ONLY LOCAL SERVER AND OFFLINE CONNECTION WILL WORK"); } }
public GameLiftServer(GameLift _gl) { gl = _gl; playerSessions = new Dictionary <int, string>(); }
public GameLiftClient(GameLift _gl) { gl = _gl; playerId = Guid.NewGuid().ToString(); Credentials.Install(); // Use command line alias if possible, otherwise use default (hard coded alias) string[] args = System.Environment.GetCommandLineArgs(); for (int i = 0; i < args.Length - 1; i++) { if (args[i] != "--alias") { //Debug.Log(":( Unrecognized command line parameter: " + args[i] + " (consider --alias <aliasId>)" + Environment.NewLine); continue; } string pattern = @"alias-[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"; Match m = Regex.Match(args[i + 1], pattern); if (m.Success) { aliasId = m.Value; Debug.Log(":) ALIAS RECOGNIZED. Alias " + aliasId + " found on command line"); break; } } // verify alias exists var config = new AmazonGameLiftConfig(); config.RegionEndpoint = Amazon.RegionEndpoint.USEast1; AmazonGameLiftClient aglc = null; AWSCredentials credentials; var chain = new CredentialProfileStoreChain(); bool profileFound = chain.TryGetAWSCredentials("demo-gamelift-unity", out credentials); if (profileFound) { Debug.Log("demo-gamelift-unity profile"); aglc = new AmazonGameLiftClient(credentials, config); } else { Debug.Log("regular profile search"); try { aglc = new AmazonGameLiftClient(config); } catch (AmazonServiceException e) { Debug.Log(e.Message); Debug.Log("AWS Credentials not found. Cannot connect to GameLift. Start application with -credentials <file> flag where credentials are the credentials.csv file containing the access and secret key."); } } if (aglc != null) { try { var dareq = new Amazon.GameLift.Model.DescribeAliasRequest(); dareq.AliasId = aliasId; Amazon.GameLift.Model.DescribeAliasResponse dares = aglc.DescribeAlias(dareq); Amazon.GameLift.Model.Alias alias = dares.Alias; Debug.Log((int)dares.HttpStatusCode + " ALIAS NAME: " + alias.Name + " (" + aliasId + ")"); if (alias.RoutingStrategy.Type == Amazon.GameLift.RoutingStrategyType.TERMINAL) { Debug.Log(" (TERMINAL ALIAS)"); } } catch (Exception e) { Debug.Log("AWS Credentials found but probably invalid. Check IAM permissions for the credentials."); Debug.Log(e.Message); } finally { aglc.Dispose(); } } }