public void SerializeLanguages()
        {
            // Check serialization produces json in the expected format
            var payload = new TelemetryPayload
            {
                SonarLintProduct              = "my product",
                SonarLintVersion              = "1.2.3.4",
                VisualStudioVersion           = "15.0.1.2",
                NumberOfDaysSinceInstallation = 234,
                NumberOfDaysOfUse             = 123,
                IsUsingConnectedMode          = true,
                IsUsingSonarCloud             = true,

                // Adding some ticks to ensure that we send just the milliseconds in the serialized payload
                InstallDate = new DateTimeOffset(2017, 12, 23, 8, 25, 35, 456, TimeSpan.FromHours(1)).AddTicks(123),
                SystemDate  = new DateTimeOffset(2018, 3, 15, 18, 55, 10, 123, TimeSpan.FromHours(1)).AddTicks(123),

                Analyses = new []
                {
                    new Analysis {
                        Language = "js"
                    },
                    new Analysis {
                        Language = "csharp"
                    },
                    new Analysis {
                        Language = "vbnet"
                    }
                }.ToList()
            };

            var serialized = TelemetryHelper.Serialize(payload);

            var expected = @"{
  ""sonarlint_product"": ""my product"",
  ""sonarlint_version"": ""1.2.3.4"",
  ""ide_version"": ""15.0.1.2"",
  ""days_since_installation"": 234,
  ""days_of_use"": 123,
  ""connected_mode_used"": true,
  ""connected_mode_sonarcloud"": true,
  ""install_time"": ""2017-12-23T08:25:35.456+01:00"",
  ""system_time"": ""2018-03-15T18:55:10.123+01:00"",
  ""analyses"": [
    {
      ""language"": ""js""
    },
    {
      ""language"": ""csharp""
    },
    {
      ""language"": ""vbnet""
    }
  ]
}";

            serialized.Should().Be(expected);
        }
Beispiel #2
0
    public void ReceiveTelemetry(TelemetryPayload payload)
    {
        // set position
        PosX.SetToNumber(Mathf.RoundToInt(payload.posx / 1000.0f));
        PosY.SetToNumber(Mathf.RoundToInt(payload.posy / 1000.0f));
        PosZ.SetToNumber(Mathf.RoundToInt(payload.posz / 1000.0f));

        // x is the y-dim and y is heading
        RotX.SetToNumber(Mathf.RoundToInt(payload.roty));
        var heading = (payload.rotx < 100) ? Mathf.CeilToInt(payload.rotx * -1) : Mathf.CeilToInt(360 - payload.rotx);

        RotY.SetToNumber(heading);
    }
Beispiel #3
0
    public void ReceiveTelemetry(TelemetryPayload payload)
    {
        // process player
        if (payload.id == "00000000-0000-0000-0000-000000000000")
        {
            Player.transform.position    = new Vector3(payload.posx, payload.posy, payload.posz);
            Player.transform.eulerAngles = new Vector3(payload.rotx, payload.roty, payload.rotz);
            return;
        }

        // process everything else
        var obj = GameObject.Find(payload.id);

        if (obj != null)
        {
            obj.transform.position    = new Vector3(payload.posx, payload.posy, payload.posz);
            obj.transform.eulerAngles = new Vector3(payload.rotx, payload.roty, payload.rotz);
        }
    }
Beispiel #4
0
        public void Serialize()
        {
            // Check serialization produces json in the expected format
            var payload = new TelemetryPayload
            {
                SonarLintProduct               = "my product",
                SonarLintVersion               = "1.2.3.4",
                VisualStudioVersion            = "15.0.1.2",
                VisualStudioVersionInformation = new IdeVersionInformation
                {
                    DisplayVersion      = "16.9.0 Preview 3.0",
                    InstallationVersion = "16.9.30914.41",
                    DisplayName         = "Visual Studio Enterprise 2019"
                },
                NumberOfDaysSinceInstallation = 234,
                NumberOfDaysOfUse             = 123,
                IsUsingConnectedMode          = true,
                IsUsingLegacyConnectedMode    = true,
                IsUsingSonarCloud             = true,

                // Adding some ticks to ensure that we send just the milliseconds in the serialized payload
                InstallDate = new DateTimeOffset(2017, 12, 23, 8, 25, 35, 456, TimeSpan.FromHours(1)).AddTicks(123),
                SystemDate  = new DateTimeOffset(2018, 3, 15, 18, 55, 10, 123, TimeSpan.FromHours(1)).AddTicks(123),

                Analyses = new []
                {
                    new Analysis {
                        Language = "js"
                    },
                    new Analysis {
                        Language = "csharp"
                    },
                    new Analysis {
                        Language = "vbnet"
                    }
                }.ToList(),
                ShowHotspot = new ShowHotspot {
                    NumberOfRequests = 567
                },
                TaintVulnerabilities = new TaintVulnerabilities {
                    NumberOfIssuesInvestigatedLocally = 654, NumberOfIssuesInvestigatedRemotely = 321
                },
                ServerNotifications = new ServerNotifications
                {
                    IsDisabled = true,
                    ServerNotificationCounters = new Dictionary <string, ServerNotificationCounter>()
                    {
                        { "QUALITY_GATE", new ServerNotificationCounter
                          {
                              ReceivedCount = 111,
                              ClickedCount  = 222
                          } },
                        { "NEW_ISSUES", new ServerNotificationCounter
                          {
                              ReceivedCount = 333,
                              ClickedCount  = 444
                          } }
                    }
                }
            };

            var serialized = TelemetryHelper.Serialize(payload);

            var expected = @"{
  ""sonarlint_product"": ""my product"",
  ""sonarlint_version"": ""1.2.3.4"",
  ""ide_version"": ""15.0.1.2"",
  ""slvs_ide_info"": {
    ""name"": ""Visual Studio Enterprise 2019"",
    ""install_version"": ""16.9.30914.41"",
    ""display_version"": ""16.9.0 Preview 3.0""
  },
  ""days_since_installation"": 234,
  ""days_of_use"": 123,
  ""connected_mode_used"": true,
  ""legacy_connected_mode_used"": true,
  ""connected_mode_sonarcloud"": true,
  ""install_time"": ""2017-12-23T08:25:35.456+01:00"",
  ""system_time"": ""2018-03-15T18:55:10.123+01:00"",
  ""analyses"": [
    {
      ""language"": ""js""
    },
    {
      ""language"": ""csharp""
    },
    {
      ""language"": ""vbnet""
    }
  ],
  ""show_hotspot"": {
    ""requests_count"": 567
  },
  ""taint_vulnerabilities"": {
    ""investigated_locally_count"": 654,
    ""investigated_remotely_count"": 321
  },
  ""server_notifications"": {
    ""disabled"": true,
    ""count_by_type"": {
      ""QUALITY_GATE"": {
        ""received"": 111,
        ""clicked"": 222
      },
      ""NEW_ISSUES"": {
        ""received"": 333,
        ""clicked"": 444
      }
    }
  }
}";

            serialized.Should().Be(expected);
        }
Beispiel #5
0
    void Update()
    {
        // advance the timers
        ElapsedFast += Time.deltaTime;
        ElapsedSlow += Time.deltaTime;

        // every 1 sec
        if (ElapsedSlow > 1.0f)
        {
            ElapsedSlow = 0.0f;

            // continue requesting zone if you don't get it
            if (IsRequestingZone)
            {
                var msg = new Message()
                {
                    c = "zone?",
                    e = 0
                };
                Network.Send(msg);
            }
        }

        // every 0.2 sec
        if (ElapsedFast > 0.2f)
        {
            ElapsedFast = 0.0f;

            // send all gameobj positions
            for (int i = 0; i < Features.transform.childCount; i++)
            {
                var obj  = Features.transform.GetChild(i);
                var go   = obj.GetComponent <GameObj>();
                var body = obj.GetComponent <Rigidbody>();
                if (go != null && body != null)
                {
                    // determine facings
                    var s2v = ClosestFacing(Player.gameObject, obj.gameObject);
                    var v2s = ClosestFacing(obj.gameObject, Player.gameObject);

                    // send telemetry data
                    var pos = body.transform.position;
                    var rot = body.transform.rotation.eulerAngles;
                    TelemetryPayload payload = new TelemetryPayload()
                    {
                        id   = go.Id.ToString(),
                        posx = Mathf.CeilToInt(pos.x),
                        posy = Mathf.CeilToInt(pos.y),
                        posz = Mathf.CeilToInt(pos.z),
                        rotx = Mathf.CeilToInt(rot.x),
                        roty = Mathf.CeilToInt(rot.y),
                        rotz = Mathf.CeilToInt(rot.z),
                        s2v  = s2v.Direction,
                        v2s  = v2s.Direction
                    };
                    var msg = new Message <TelemetryPayload>()
                    {
                        c = "telemetry",
                        p = payload,
                        e = 0
                    };
                    Network.Send(msg);
                }
            }
        }
    }