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 CreateSession()
        {
            RemoteRenderingClient client = GetClientWithAccountKey();

            #region Snippet:CreateASession

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

            // A randomly generated GUID is a good choice for a sessionId.
            string sessionId = Guid.NewGuid().ToString();

            StartRenderingSessionOperation startSessionOperation = client.StartSession(sessionId, options);

            RenderingSession newSession = startSessionOperation.WaitForCompletionAsync().Result;
            if (newSession.Status == RenderingSessionStatus.Ready)
            {
                Console.WriteLine($"Session {sessionId} is ready.");
            }
            else if (newSession.Status == RenderingSessionStatus.Error)
            {
                Console.WriteLine($"Session {sessionId} encountered an error: {newSession.Error.Code} {newSession.Error.Message}");
            }

            #endregion Snippet:CreateASession

            // Use the session here.
            // ...

            // The session will automatically timeout, but in this sample we also demonstrate how to shut it down explicitly.
            #region Snippet:StopSession

            client.StopSession(sessionId);

            #endregion Snippet:StopSession
        }
 public RemoteRenderingConnectionEventArgs(
     RenderingSession session,
     ConnectionStatus connectionStatus)
 {
     Session          = session;
     ConnectionStatus = connectionStatus;
 }
        /// <summary>
        /// Create a new remote <see cref="ARREntity"/> to associate with the proxy <see cref="EvergineEntity"/>.
        /// <para>
        /// This function will throw if this <see cref="ARREntitySync"/> already has a remote entity.
        /// </para>
        /// </summary>
        /// <param name="session">
        /// The azure session used to create the remote <see cref="ARREntity"/>.
        /// </param>
        public void CreateRemoteEntity(RenderingSession session)
        {
            if (session is null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            if (session.ConnectionStatus != ConnectionStatus.Connected)
            {
                return;
            }

            if (!this.IsRemoteEntityValid)
            {
                this.RemoteEntity = session.Connection.CreateEntity();
            }
            else
            {
                throw new Exception($"Trying to create an already created {nameof(ARREntitySync)}");
            }

            if (this.IsRemoteEntityValid)
            {
                BindToLocalEntity(this.RemoteEntity, this.Owner);
                this.SyncToRemote();
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
    private async void LogSessionStatus(RenderingSession session)
    {
        if (session != null)
        {
            var sessionProperties = await session.GetPropertiesAsync();

            LogSessionStatus(sessionProperties.SessionProperties);
        }
        else
        {
            var sessionProperties = arrService.LastProperties;
            LogMessage($"Session ended: Id={sessionProperties.Id}");
        }
    }
Ejemplo n.º 7
0
 private void ARRService_OnSessionStatusChanged(ARRServiceUnity service, RenderingSession session)
 {
     LogSessionStatus(session);
 }