Ejemplo n.º 1
0
        public void QueryAndUpdateASession()
        {
            RemoteRenderingClient client = GetClientWithAccountKey();

            string sessionId = Guid.NewGuid().ToString();

            RenderingSessionOptions settings = new RenderingSessionOptions(TimeSpan.FromMinutes(30), RenderingServerSize.Standard);

            RenderingSession newSession = client.StartSession(sessionId, settings).WaitForCompletionAsync().Result;

            #region Snippet:UpdateSession

            RenderingSession currentSession = client.GetSession(sessionId);

            if (currentSession.MaxLeaseTime - DateTimeOffset.Now.Subtract(currentSession.CreatedOn.Value) < TimeSpan.FromMinutes(2))
            {
                TimeSpan newLeaseTime = currentSession.MaxLeaseTime.Value.Add(TimeSpan.FromMinutes(30));

                UpdateSessionOptions longerLeaseSettings = new UpdateSessionOptions(newLeaseTime);

                client.UpdateSession(sessionId, longerLeaseSettings);
            }

            #endregion Snippet:UpdateSession

            client.StopSession(sessionId);
        }
Ejemplo n.º 2
0
 public void Set(UpdateSessionOptions other)
 {
     if (other != null)
     {
         m_ApiVersion = SessionsInterface.UpdatesessionApiLatest;
         SessionModificationHandle = other.SessionModificationHandle;
     }
 }
Ejemplo n.º 3
0
        public async Task TestSimpleSession()
        {
            var client = GetClient();

            RenderingSessionOptions options = new RenderingSessionOptions(TimeSpan.FromMinutes(4), RenderingServerSize.Standard);

            string sessionId = Recording.Random.NewGuid().ToString();

            StartRenderingSessionOperation startSessionOperation = await client.StartSessionAsync(sessionId, options);

            Assert.IsTrue(startSessionOperation.HasValue);
            Assert.AreEqual(options.Size, startSessionOperation.Value.Size);
            Assert.AreEqual(sessionId, startSessionOperation.Value.SessionId);

            RenderingSession sessionProperties = await client.GetSessionAsync(sessionId);

            Assert.AreEqual(startSessionOperation.Value.CreatedOn, sessionProperties.CreatedOn);

            UpdateSessionOptions updateOptions = new UpdateSessionOptions(TimeSpan.FromMinutes(5));

            RenderingSession updatedSession = await client.UpdateSessionAsync(sessionId, updateOptions);

            Assert.AreEqual(updatedSession.MaxLeaseTime, TimeSpan.FromMinutes(5));

            RenderingSession readyRenderingSession = await startSessionOperation.WaitForCompletionAsync();

            Assert.IsTrue((readyRenderingSession.MaxLeaseTime == TimeSpan.FromMinutes(4)) || (readyRenderingSession.MaxLeaseTime == TimeSpan.FromMinutes(5)));
            Assert.IsNotNull(readyRenderingSession.Host);
            Assert.IsNotNull(readyRenderingSession.ArrInspectorPort);
            Assert.IsNotNull(readyRenderingSession.HandshakePort);
            Assert.AreEqual(readyRenderingSession.Size, options.Size);

            UpdateSessionOptions updateOptions2 = new UpdateSessionOptions(TimeSpan.FromMinutes(6));

            Assert.AreEqual(TimeSpan.FromMinutes(6), updateOptions2.MaxLeaseTime);

            bool foundSession = false;

            await foreach (var s in client.GetSessionsAsync())
            {
                if (s.SessionId == sessionId)
                {
                    foundSession = true;
                }
            }
            Assert.IsTrue(foundSession);
            await client.StopSessionAsync(sessionId);

            RenderingSession stoppedRenderingSession = await client.GetSessionAsync(sessionId);

            Assert.AreEqual(RenderingSessionStatus.Stopped, stoppedRenderingSession.Status);
        }