/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateFleetResponse response = new CreateFleetResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("arn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Arn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("createdAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreatedAt = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateFleetResponse response = new CreateFleetResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("FleetAttributes", targetDepth)) { var unmarshaller = FleetAttributesUnmarshaller.Instance; response.FleetAttributes = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("LocationStates", targetDepth)) { var unmarshaller = new ListUnmarshaller <LocationState, LocationStateUnmarshaller>(LocationStateUnmarshaller.Instance); response.LocationStates = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { CreateFleetResponse response = new CreateFleetResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth = 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("fleetId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.FleetId = unmarshaller.Unmarshall(context); continue; } } } return(response); }
public static CreateFleetResponse Unmarshall(UnmarshallerContext context) { CreateFleetResponse createFleetResponse = new CreateFleetResponse(); createFleetResponse.HttpResponse = context.HttpResponse; createFleetResponse.RequestId = context.StringValue("CreateFleet.RequestId"); createFleetResponse.FleetId = context.StringValue("CreateFleet.FleetId"); return(createFleetResponse); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateFleetResponse response = new CreateFleetResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Fleet", targetDepth)) { var unmarshaller = FleetUnmarshaller.Instance; response.Fleet = unmarshaller.Unmarshall(context); continue; } } return(response); }
static async Task <string> CreateFleet(string name, string version, string buildId) { var config = new AmazonGameLiftConfig(); config.RegionEndpoint = region; using (AmazonGameLiftClient aglc = new AmazonGameLiftClient(config)) { // create launch configuration var serverProcess = new ServerProcess(); serverProcess.ConcurrentExecutions = 1; serverProcess.LaunchPath = @"C:\game\GameLiftUnity.exe"; // @"/local/game/ReproGLLinux.x86_64"; serverProcess.Parameters = "-batchmode -nographics"; // create inbound IP permissions var permission1 = new IpPermission(); permission1.FromPort = 1935; permission1.ToPort = 1935; permission1.Protocol = IpProtocol.TCP; permission1.IpRange = "0.0.0.0/0"; // create inbound IP permissions var permission2 = new IpPermission(); permission2.FromPort = 3389; permission2.ToPort = 3389; permission2.Protocol = IpProtocol.TCP; permission2.IpRange = "0.0.0.0/0"; // create fleet var cfreq = new CreateFleetRequest(); cfreq.Name = name; cfreq.Description = version; cfreq.BuildId = buildId; cfreq.EC2InstanceType = EC2InstanceType.C4Large; cfreq.EC2InboundPermissions.Add(permission1); cfreq.EC2InboundPermissions.Add(permission2); cfreq.RuntimeConfiguration = new RuntimeConfiguration(); cfreq.RuntimeConfiguration.ServerProcesses = new List <ServerProcess>(); cfreq.RuntimeConfiguration.ServerProcesses.Add(serverProcess); cfreq.NewGameSessionProtectionPolicy = ProtectionPolicy.NoProtection; CreateFleetResponse cfres = await aglc.CreateFleetAsync(cfreq); // set fleet capacity var ufcreq = new UpdateFleetCapacityRequest(); ufcreq.MinSize = 0; ufcreq.DesiredInstances = 1; ufcreq.MaxSize = 1; ufcreq.FleetId = cfres.FleetAttributes.FleetId; UpdateFleetCapacityResponse ufcres = await aglc.UpdateFleetCapacityAsync(ufcreq); // set scaling rule (switch fleet off after 1 day of inactivity) // If [MetricName] is [ComparisonOperator] [Threshold] for [EvaluationPeriods] minutes, then [ScalingAdjustmentType] to/by [ScalingAdjustment]. var pspreq = new PutScalingPolicyRequest(); pspreq.Name = "Switch fleet off after 1 day of inactivity"; pspreq.MetricName = MetricName.ActiveGameSessions; pspreq.ComparisonOperator = ComparisonOperatorType.LessThanOrEqualToThreshold; pspreq.Threshold = 0.0; // double (don't use int) pspreq.EvaluationPeriods = 1435; // just under 1 day, 1435 appears to be the maximum permitted value now. pspreq.ScalingAdjustmentType = ScalingAdjustmentType.ExactCapacity; pspreq.ScalingAdjustment = 0; pspreq.FleetId = cfres.FleetAttributes.FleetId; PutScalingPolicyResponse pspres = await aglc.PutScalingPolicyAsync(pspreq); return(cfres.FleetAttributes.FleetId); } }