<commit_before>var defaultOptions = {
  url: 'http://localhost:8080/now',
  use_tcp: false
}

// if node
var util = require('./util');
var BridgeSerialize = require('./bridgeserialize.js');
var createTCPConn = require('./tcp').createTCPConn
var Connection = require('./connection');
var defaultOptions = {
  host: 'localhost',
  port: 8090,
  use_tcp: true
}
// end node


function WebConnection(onReady, onMessage, options) {
  var self = this;

  this.onMessage = onMessage;

  // Merge passed in options into default options
  this.options = util.extend(defaultOptions, options);

  if (this.options.use_tcp) {
    console.log('TCP CONN', this.options.host, this.options.port);
    this.sock = createTCPConn(this.options);
  } else {
    this.sock = new SockJS(this.options.url, this.options.protocols, this.options.sockjs); 
  }
  this.sock.onopen = function() {
    console.log("Waiting for clientId");
  
  };
  this.sock.onmessage = function(message){
    console.log("clientId======", message.data);
    var ids = message.data.toString().split('|');
    self.sock._connid = ids[0];
    self.clientId = ids[0];
    self.secret = ids[1];

    self.sock.onmessage = self.onData.bind(self);
    onReady();
  };
  this.sock.onclose = function() {
    util.warn("WebConnection closed");
  };
}

util.inherit(WebConnection, Connection);

WebConnection.prototype.onData = function(message) {
  var self = this;
  try {
    util.info('hi', message, message.data);
    var message = util.parse(message.data);    
    self.onMessage(message);
  } catch (e) {
    util.error("Message parsing failed: ", e.message, e.stack);<commit_msg>pass secret into client<commit_after>var defaultOptions = {
  url: 'http://localhost:8080/now',
  use_tcp: false
}

// if node
var util = require('./util');
var BridgeSerialize = require('./bridgeserialize.js');
var createTCPConn = require('./tcp').createTCPConn
var Connection = require('./connection');
var defaultOptions = {
  host: 'localhost',
  port: 8090,
  use_tcp: true
}
// end node


function WebConnection(onReady, onMessage, options) {
  var self = this;

  this.onMessage = onMessage;

  // Merge passed in options into default options
  this.options = util.extend(defaultOptions, options);

  if (this.options.use_tcp) {
    console.log('TCP CONN', this.options.host, this.options.port);
    this.sock = createTCPConn(this.options);
  } else {
    this.sock = new SockJS(this.options.url, this.options.protocols, this.options.sockjs); 
  }
  this.sock.onopen = function() {
    console.log("Waiting for clientId");
  
  };
  this.sock.onmessage = function(message){
    console.log("clientId======", message.data);
    var ids = message.data.toString().split('|');
    self.clientId = ids[0];
    self.secret = ids[1];

    self.sock.onmessage = self.onData.bind(self);
    onReady();
  };
  this.sock.onclose = function() {
    util.warn("WebConnection closed");
  };
}

util.inherit(WebConnection, Connection);

WebConnection.prototype.onData = function(message) {
  var self = this;
  try {
    util.info('hi', message, message.data);
    var message = util.parse(message.data);    
    self.onMessage(message);
  } catch (e) {
    util.error("Message parsing failed: ", e.message, e.stack);
{'fraction_non_alphanumeric': 0.1580246913580247, 'fraction_numerical': 0.006481481481481481, 'mean_word_length': 3.7039187227866472, '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': '7083674', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1032, 'n_words': 220}