<commit_before>var cp = require('child_process');
var events = require('events');
var util = require('util');
var ipUtil = require('ip-util');

function ProxyServer() {
  this.proxyUrl = '';
  // For now this is onvif only
  this.streamUrl = '';
}

util.inherits(ProxyServer, events.EventEmitter);

ProxyServer.prototype.createServer = function(path, callback) {
  try {
    this.server = cp.fork(path);
  } catch(e) {
    callback(e);
  }
  this.server.on('message', function(msg) {
    if (msg.port) {
      var port = msg.port;
      var protocol = ipUtil.getHostProtocol();
      var hostIp = ipUtil.getHostIp();
      this.proxyUrl = protocol + hostIp + ':' + port;
      this.emit('proxyurl', this.proxyUrl);
    } else if (msg.streamUrl) {
      // For now this is onvif only
      this.streamUrl = msg.streamUrl;
      this.emit('streamurl', this.streamUrl);
    }
  }.bind(this));
  callback(null);
};

ProxyServer.prototype.setDeviceRootUrl = function(url) {
  this.server.send({deviceRootUrl: url});
};

// For now this is onvif only
ProxyServer.prototype.setDeviceStreamUrl = function(url) {
  this.server.send({deviceStreamUrl: url});
};

module.exports = ProxyServer;<commit_msg>add device id setting to proxy server code<commit_after>var cp = require('child_process');
var events = require('events');
var util = require('util');
var ipUtil = require('ip-util');

function ProxyServer() {
  this.proxyUrl = '';
  // For now this is onvif only
  this.streamUrl = '';
}

util.inherits(ProxyServer, events.EventEmitter);

ProxyServer.prototype.createServer = function(path, callback) {
  try {
    this.server = cp.fork(path);
  } catch(e) {
    callback(e);
  }
  this.server.on('message', function(msg) {
    if (msg.port) {
      var port = msg.port;
      var protocol = ipUtil.getHostProtocol();
      var hostIp = ipUtil.getHostIp();
      this.proxyUrl = protocol + hostIp + ':' + port;
      this.emit('proxyurl', this.proxyUrl);
    } else if (msg.streamUrl) {
      // For now this is onvif only
      this.streamUrl = msg.streamUrl;
      this.emit('streamurl', this.streamUrl);
    }
  }.bind(this));
  callback(null);
};

ProxyServer.prototype.setDeviceID = function(id) {
  this.server.send({deviceID: id});
};

ProxyServer.prototype.setDeviceRootUrl = function(url) {
  this.server.send({deviceRootUrl: url});
};

// For now this is onvif only
ProxyServer.prototype.setDeviceStreamUrl = function(url) {
  this.server.send({deviceStreamUrl: url});
};

module.exports = ProxyServer;
{'fraction_non_alphanumeric': 0.1524341580207502, 'fraction_numerical': 0.0, 'mean_word_length': 3.659851301115242, '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': '7186915', 'n_tokens_mistral': 819, 'n_tokens_neox': 815, 'n_words': 174}