Beispiel #1
0
        async Task ConnectToAgentAsync(CancellationToken cancellationToken)
        {
            if (agent.IsConnected)
            {
                agent = agent.TerminateConnection();
            }

            if (SessionKind == ClientSessionKind.Workbook)
            {
                WorkbookApp = WorkbookAppInstallation.Locate(agent.Type);
            }

            agent = await agent.ConnectAsync(
                WorkbookApp,
                Uri,
                ViewControllers.Messages,
                HandleAgentDisconnected,
                cancellationTokenSource.Token);

            agent.Api.EvaluationContextManager.Events.Subscribe(
                new Observer <ICodeCellEvent> (HandleCodeCellEvent));

            await agent.Api.SetLogLevelAsync(Log.GetLogLevel());

            UpdateTitle();

            PostEvent(ClientSessionEventKind.AgentConnected);

            new Telemetry.Models.AgentSession {
                AppSessionId = ClientApp.SharedInstance.AppSessionId,
                Timestamp    = DateTimeOffset.UtcNow,
                Flavor       = agent.Identity.FlavorId,
                Kind         = (Telemetry.Models.AgentSessionKind)(int) SessionKind
            }.Post();
        }
Beispiel #2
0
        async Task ConnectToAgentAsync(CancellationToken cancellationToken)
        {
            if (agent.IsConnected)
            {
                agent = agent.TerminateConnection();
            }

            if (SessionKind == ClientSessionKind.Workbook)
            {
                WorkbookApp = WorkbookAppInstallation.Locate(agent.Type);
            }

            agent = await agent.ConnectAsync(
                WorkbookApp,
                Uri,
                ViewControllers.Messages,
                HandleAgentDisconnected,
                cancellationTokenSource.Token);

            agent.Api.Messages.Subscribe(new Observer <object> (HandleAgentMessage));

            await agent.Api.SetLogLevelAsync(Log.GetLogLevel());

            UpdateTitle();

            PostEvent(ClientSessionEventKind.AgentConnected);
        }
Beispiel #3
0
        async Task ConnectToAgentAsync(CancellationToken cancellationToken)
        {
            if (agent.IsConnected)
            {
                agent = agent.TerminateConnection();
            }

            if (SessionKind == ClientSessionKind.Workbook)
            {
                WorkbookApp = WorkbookAppInstallation.Locate(agent.Type);
            }

            agent = await agent.ConnectAsync(
                WorkbookApp,
                Uri,
                ViewControllers.Messages,
                HandleAgentDisconnected,
                cancellationTokenSource.Token);

            agent.Api.EvaluationContextManager.Events.Subscribe(
                new Observer <ICodeCellEvent> (HandleCodeCellEvent));

            await agent.Api.SetLogLevelAsync(Log.GetLogLevel());

            UpdateTitle();

            PostEvent(ClientSessionEventKind.AgentConnected);

            // May be set by Inspector extensions to allow correlating client telemetry with IDE telemetry
            var externalTelemetrySessionId = Uri
                                             .Parameters
                                             .FirstOrDefault(p => p.Key == "TelemetrySessionId")
                                             .Value;

            new Telemetry.Models.AgentSession {
                AgentFlavor = agent.Identity.FlavorId,
                ClientKind  = SessionKind,
                ExternalTelemetrySessionId = externalTelemetrySessionId
            }.Post();
        }