{"size": 590, "ext": "js", "max_stars_repo_path": "docs/user-guide/resources/telemetry-websocket-example.js", "max_stars_repo_name": "shryu84/thingsboard.github.io", "max_stars_repo_stars_event_min_datetime": "2016-12-06T12:44:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T10:29:49.000Z", "max_issues_repo_path": "docs/user-guide/resources/telemetry-websocket-example.js", "max_issues_repo_name": "shryu84/thingsboard.github.io", "max_issues_repo_issues_event_min_datetime": "2016-12-12T09:35:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-27T13:18:09.000Z", "max_forks_repo_path": "docs/user-guide/resources/telemetry-websocket-example.js", "max_forks_repo_name": "avlo/user-guide", "max_forks_repo_forks_event_min_datetime": "2016-12-07T22:12:02.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-25T01:33:58.000Z"}
{"max_stars_count": 105, "max_issues_count": 190, "max_forks_count": 287, "avg_line_length": 29.5, "max_line_length": 110, "alphanum_fraction": 0.6915254237}
var connection = new WebSocket('ws://localhost:8080/api/ws/plugins/telemetry?token=' + process.env.JWT_TOKEN);

connection.onopen = function () {
  // connection is opened and ready to use
};

connection.onerror = function (error) {
  // an error occurred when sending/receiving data
};

connection.onmessage = function (message) {
  // try to decode json (I assume that each message from server is json)
  try {
    var json = JSON.parse(message.data);
  } catch (e) {
    console.log('This doesn\'t look like a valid JSON: ', message.data);
    return;
  }
  // handle incoming message
};