Ejemplo n.º 1
0
        protected override void OnOpen()
        {
            try
            {
                string deviceSerial = this.Context.Headers.GetValues("device-serial").FirstOrDefault();

                DeviceModel objDevice = DevicePool.GetDevice(deviceSerial);
                if (objDevice == null)
                {
                    using (var ctx = new DeviceMgmtEntities())
                    {
                        objDevice = ctx.Devices.Where(d => d.DeviceSerialNr.Equals(deviceSerial)).Select(dvc => new DeviceModel()
                        {
                            DeviceID = dvc.ID, DeviceDescription = dvc.Description, DeviceName = dvc.Name, DeviceSerialNumber = dvc.DeviceSerialNr, DeviceType = dvc.DeviceType, SessionId = this.ID
                        }).FirstOrDefault();
                    }
                    DevicePool.AddDevice(objDevice);
                }
                else
                {
                    DevicePool.UpdateDeviceSession(objDevice.DeviceSerialNumber, this.ID);
                }
            }
            catch
            {
                //Logs goes here...
            }
        }
Ejemplo n.º 2
0
 public TvDiscovery(IDeviceDiscovery upnpDiscovery, INetworkTransport networkTransport)
 {
     this.transport     = networkTransport;
     this.upnpDiscovery = upnpDiscovery;
     this.upnpDiscovery.DeviceConnected    += new EventHandler <DeviceInfoEventArgs>(this.upnpDiscovery_DeviceConnected);
     this.upnpDiscovery.DeviceDisconnected += new EventHandler <DeviceInfoEventArgs>(this.upnpDiscovery_DeviceDisconnected);
     this.devicePool                = new DevicePool();
     this.devicePool.DeviceAdded   += new EventHandler <DeviceInfoEventArgs>(this.devicePool_DeviceAdded);
     this.devicePool.DeviceRemoved += new EventHandler <DeviceInfoEventArgs>(this.devicePool_DeviceRemoved);
 }
Ejemplo n.º 3
0
        public void DeviceFarmGetDevicePool()
        {
            #region getdevicepool-example-1470870873136

            var response = client.GetDevicePool(new GetDevicePoolRequest
            {
                Arn = "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456" // You can obtain the project ARN by using the list-projects CLI command.
            });

            DevicePool devicePool = response.DevicePool;

            #endregion
        }
 public JsonResult Control(DeviceActionModel model)
 {
     try
     {
         var device = DevicePool.GetDevice(model.DeviceSerial);
         MvcApplication.objWsServer.WebSocketServices["/"].Sessions.SendTo(new JavaScriptSerializer().Serialize(model), device.SessionId);
         return(Json(true));
     }
     catch
     {
         return(Json(false));
     }
 }
Ejemplo n.º 5
0
        public void DeviceFarmCreateDevicePool()
        {
            #region createdevicepool-example-1470862210860

            var response = client.CreateDevicePool(new CreateDevicePoolRequest
            {
                Name        = "MyDevicePool",                                                           // A device pool contains related devices, such as devices that run only on Android or that run only on iOS.
                Description = "My Android devices",
                ProjectArn  = "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", // You can get the project ARN by using the list-projects CLI command.
                Rules       = new List <Rule> {
                }
            });

            DevicePool devicePool = response.DevicePool;

            #endregion
        }
Ejemplo n.º 6
0
        private DevicePool CreateDefaultDevicePool(string projectArn)
        {
            Log.LogMessage("Creating device pool {0}.", DefaultDevicePoolName);
            string        nextToken = null;
            List <Device> devices   = new List <Device>();

            do
            {
                var resp = DFClient.ListDevices(new ListDevicesRequest()
                {
                    NextToken = nextToken
                });
                nextToken = resp.NextToken;
                devices.AddRange(resp.Devices);
            } while (nextToken != null);

            List <string> deviceArns = new List <string>();

            foreach (var device in devices)
            {
                if (DefaultDevices.ContainsKey(device.Name) && DefaultDevices[device.Name] == device.Os)
                {
                    deviceArns.Add('"' + device.Arn + '"');
                }
            }
            Rule rule = new Rule()
            {
                Attribute = DeviceAttribute.ARN,
                Operator  = RuleOperator.IN,
                Value     = "[" + string.Join(",", deviceArns) + "]"
            };
            DevicePool devicePool = DFClient.CreateDevicePool(new CreateDevicePoolRequest()
            {
                ProjectArn = projectArn,
                Name       = DefaultDevicePoolName,
                Rules      = new List <Rule>()
                {
                    rule
                }
            }).DevicePool;

            return(devicePool);
        }
Ejemplo n.º 7
0
        public void DeviceFarmUpdateDevicePool()
        {
            #region to-update-a-device-pool-1472653887677

            var response = client.UpdateDevicePool(new UpdateDevicePoolRequest
            {
                Name        = "NewName",
                Arn         = "arn:aws:devicefarm:us-west-2::devicepool:082d10e5-d7d7-48a5-ba5c-12345EXAMPLE", // You can get the Amazon Resource Name (ARN) of the device pool by using the list-pools CLI command.
                Description = "NewDescription",
                Rules       = new List <Rule> {
                    new Rule {
                        Value     = "True",
                        Attribute = "REMOTE_ACCESS_ENABLED",
                        Operator  = "EQUALS"
                    }
                }
            });

            DevicePool devicePool = response.DevicePool; // Note: you cannot update curated device pools.

            #endregion
        }
Ejemplo n.º 8
0
        private DevicePool GetDevicePool(string projectArn, string devicePoolName)
        {
            DevicePool devicePool = null;
            string     nextToken  = null;

            do
            {
                var response = DFClient.ListDevicePools(new ListDevicePoolsRequest()
                {
                    Arn       = projectArn,
                    Type      = DevicePoolType.CURATED,
                    NextToken = nextToken
                });
                nextToken = response.NextToken;
                foreach (var dp in response.DevicePools)
                {
                    if (dp.Name == devicePoolName)
                    {
                        devicePool = dp;
                        break;
                    }
                }
            } while (devicePool == null && !string.IsNullOrEmpty(nextToken));

            if (devicePool != null)
            {
                Log.LogMessage("Found device pool named '{0}' with ARN '{1}'.", devicePoolName, devicePool.Arn);
            }
            else if (devicePoolName == DefaultDevicePoolName)
            {
                return(CreateDefaultDevicePool(projectArn));
            }
            else
            {
                throw new System.ArgumentException(string.Format("Cannot find device pool named '{0}'.", devicePoolName));
            }

            return(devicePool);
        }
Ejemplo n.º 9
0
        public override void TickTest()
        {
            AccountPool.Instance.RegisterAccount(new EpicAccount("Foo", "Bar"));

            // Add three devices to the pool
            DevicePool.Instance.RegisterDevices(new ITargetDevice[] {
                new TargetDeviceWindows("Local PC1", Globals.TempDir)
                , new TargetDeviceWindows("Local PC2", Globals.TempDir)
            });

            // Create a new build (params come from our base class will be similar to "OrionGame" and "p:\builds\orion\branch-cl")
            UnrealBuildSource Build = new UnrealBuildSource(this.GameName, this.UsesSharedBuildType, Environment.CurrentDirectory, this.BuildPath, new string[] { "" });

            // create a new options structure
            UnrealOptions Options = new UnrealOptions();

            // set the mapname, this will be applied automatically to the server
            Options.Map = "OrionEntry";
            Options.Log = true;

            // add some common options.
            string ServerArgs = " -nomcp -log";

            // We want the client to connect to the server, so get the IP address of this PC and add it to the client args as an ExecCmd
            string LocalIP    = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(o => o.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).First().ToString();
            string ClientArgs = string.Format(" -ExecCmds=\"open {0}\"", LocalIP);

            // create a new session with client & server roles
            UnrealSession Session = new UnrealSession(Build, new[] {
                new UnrealSessionRole(UnrealTargetRole.Client, UnrealTargetPlatform.PS4, UnrealTargetConfiguration.Development, ClientArgs, Options)
                , new UnrealSessionRole(UnrealTargetRole.Server, UnrealTargetPlatform.Win64, UnrealTargetConfiguration.Development, ServerArgs, Options)
            });

            // launch an instance of this session
            UnrealSessionInstance SessionInstance = Session.LaunchSession();

            // wait for two minutes - long enough for anything to go wrong :)
            DateTime StartTime = DateTime.Now;

            while (SessionInstance.ClientsRunning && SessionInstance.ServerRunning)
            {
                if ((DateTime.Now - StartTime).TotalSeconds > 120)
                {
                    break;
                }

                Thread.Sleep(1000);
            }

            // check these are both still running
            CheckResult(SessionInstance.ClientsRunning, "Clients exited during test");
            CheckResult(SessionInstance.ServerRunning, "Server exited during test");

            // shutdown the session
            SessionInstance.Shutdown();

            // shutdown the pools
            AccountPool.Shutdown();
            DevicePool.Shutdown();

            MarkComplete(TestResult.Passed);
        }