<commit_before>// This server just broadcasts all messages to all clients.

const WebSocketServer = require("ws").Server

let wss = new WebSocketServer({port: 9090})

wss.on("connection", function(ws) {
  console.log(`hello ${ws.address}`)

  ws.on("message", function(message) {
    console.log("bouncing: %s", message)

    for (let client of wss.clients) {
      client.send(message);
    }
  })

  ws.on("close", function() {
    console.log(`goodbye ${ws.address}`)
  })

  ws.send("hello");
})

console.log("server running...")
<commit_msg>use a Connection object for better server debug info<commit_after>// This server just broadcasts all messages to all clients.

const WebSocketServer = require("ws").Server

let wss = new WebSocketServer({port: 9090})

class Connection {
  constructor(ws) {
    this.ws = ws

    console.log(`hello ${this.clientName()}`)
  }

  clientName() {
    return `${this.ws._socket.remoteAddress}:${this.ws._socket.remotePort}`
  }

  close() {
    console.log(`goodbye ${this.clientName()}`)
  }
}

wss.on("connection", function(ws) {
  let connection = new Connection(ws)

  ws.on("message", function(message) {
    console.log("bouncing: %s", message)

    for (let client of wss.clients) {
      client.send(message)
    }
  })

  ws.on("close", () => connection.close())

  ws.send("hello")
})

console.log("server running...")

{'fraction_non_alphanumeric': 0.17007299270072992, 'fraction_numerical': 0.00583941605839416, 'mean_word_length': 3.7604166666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4279933', 'n_tokens_mistral': 471, 'n_tokens_neox': 444, 'n_words': 101}