<commit_before>'use strict'

var hat = require('hat')
var socket = require('../index')
var winston = require('winston')

var aliceId = hat()
var bobId = hat()

var socketAlice = socket(aliceId, bobId)
var socketBob = socket(bobId, aliceId)

var testQuestion = 'What is the meaning of life?'
var testAnswer = 'A movie.'

// error handlers
socketAlice.on('error', function (error) {
  winston.error(error)
})
socketBob.on('error', function (error) {
  winston.error(error)
})

// message handlers
socketAlice.on('message', function (message) {
  winston.info('Alice received answer: ' + message)
  socketAlice.closeP()
    .then(function (){
      winston.info("Alice's socket has closed")
      return socketBob.closeP()
    })
    .then(function () {
      winston.info("Bob's socket has closed")
    })
    .catch(function (error) {
      winston.error(error)
    })
})
socketBob.on('message', function (message) {
  winston.info('Bob received question: ' + message)
  socketBob.send(testAnswer)
})

socketAlice.connectP()
  .then(function (){
    winston.info("Alice's socket is ready")
    return socketBob.connectP()
  })
  .then(function () {
    winston.info("Bob's socket is ready")
    socketAlice.send(testQuestion)
  })
  .catch(function (error) {
    winston.error(error)
  })<commit_msg>minor update<commit_after>'use strict'

var hat = require('hat')
var socket = require('../index')
var winston = require('winston')

var aliceId = hat()
var bobId = hat()

var socketAlice = socket(aliceId, bobId)
var socketBob = socket(bobId, aliceId)

var testQuestion = 'What is the meaning of life?'
var testAnswer = 'A movie.'

// error handlers
socketAlice.on('error', function (error) {
  winston.error(error)
})
socketBob.on('error', function (error) {
  winston.error(error)
})

// message handlers
socketAlice.on('message', function (message) {
  winston.info('Alice received answer: ' + message)
  socketAlice.closeP()
    .then(function () {
      winston.info("Alice's socket has closed")
      return socketBob.closeP()
    })
    .then(function () {
      winston.info("Bob's socket has closed")
    })
    .catch(function (error) {
      winston.error(error)
    })
})
socketBob.on('message', function (message) {
  winston.info('Bob received question: ' + message)
  socketBob.send(testAnswer)
})

socketAlice.connectP()
  .then(function () {
    winston.info("Alice's socket is ready")
    return socketBob.connectP()
  })
  .then(function () {
    winston.info("Bob's socket is ready")
    socketAlice.send(testQuestion)
  })
  .catch(function (error) {
    winston.error(error)
  })
{'fraction_non_alphanumeric': 0.15313582146979607, 'fraction_numerical': 0.0, 'mean_word_length': 3.8507462686567164, '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': '7361899', 'n_tokens_mistral': 897, 'n_tokens_neox': 857, 'n_words': 195}