<commit_before>var context = require('../context');

context.createAction('machine:machines:get', function (params) {
  return this.client.getMachines({
    dataCenter: params.dataCenter,
    userId: params.userId
  });
});

context.createAction('machine:filter:update', function (params) {
  return {
    filter: params.filter
  };
});

context.createAction('machine:get', function (params) {
  return this.client.getMachine({
    userId: params.userId,
    machineId: params.machineId,
    dataCenter: params.dataCenter
  });
});

context.createAction('machine:poll', function (params) {
  var self = this;
  // TODO(schoon) - Retry on error?
  // TODO(schoon) - Reconnect on close.
  var ws = new WebSocket('ws://localhost:8080/datacenters/' + params.dataCenter + '/users/' + params.userId + '/machines/' + params.machineId);

  ws.onmessage = function (event) {
    self.dispatcher.dispatch('machine:poll:update', JSON.parse(event.data));
  };
});

context.createAction('machine:poll:stop', function (params) {
  clearInterval(this['timer:' + params.machineId]);
});

context.createAction('machine:reboot', function (params) {
  return this.client.rebootMachine({
    userId: params.userId,
    machineId: params.machineId,
    dataCenter: params.dataCenter
  });
});<commit_msg>WS: Fix hardcoded host for WebSockets.<commit_after>var context = require('../context');

context.createAction('machine:machines:get', function (params) {
  return this.client.getMachines({
    dataCenter: params.dataCenter,
    userId: params.userId
  });
});

context.createAction('machine:filter:update', function (params) {
  return {
    filter: params.filter
  };
});

context.createAction('machine:get', function (params) {
  return this.client.getMachine({
    userId: params.userId,
    machineId: params.machineId,
    dataCenter: params.dataCenter
  });
});

context.createAction('machine:poll', function (params) {
  var self = this;
  // TODO(schoon) - Retry on error?
  // TODO(schoon) - Reconnect on close.
  var ws = new WebSocket('ws://' + window.location.host + '/datacenters/' + params.dataCenter + '/users/' + params.userId + '/machines/' + params.machineId);

  ws.onmessage = function (event) {
    self.dispatcher.dispatch('machine:poll:update', JSON.parse(event.data));
  };
});

context.createAction('machine:poll:stop', function (params) {
  clearInterval(this['timer:' + params.machineId]);
});

context.createAction('machine:reboot', function (params) {
  return this.client.rebootMachine({
    userId: params.userId,
    machineId: params.machineId,
    dataCenter: params.dataCenter
  });
});
{'fraction_non_alphanumeric': 0.1616122840690979, 'fraction_numerical': 0.0015355086372360845, 'mean_word_length': 4.509513742071881, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1034991', 'n_tokens_mistral': 813, 'n_tokens_neox': 806, 'n_words': 153}