<commit_before>require_relative '../handler'
require_relative '../message'

module Kamerling module Server class Sock
  attr_reader :addr

  def initialize addr: req(:addr), handler: Handler.new
    @addr    = addr
    @handler = handler
  end

  def join
    thread.join
  end

  def start
    @thread = Thread.new { run_loop }
    wait_till_started
    self
  end

  def stop
    thread.exit.join
  end

  attr_reader :handler, :thread
  private     :handler, :thread

  private

  def handle input, client_addr
    handler.handle Message.new(input), client_addr
  rescue Message::UnknownType
  end
end end end<commit_msg>Server::Sock#handle: explicitly ignore unknown inputs<commit_after>require_relative '../handler'
require_relative '../message'

module Kamerling module Server class Sock
  attr_reader :addr

  def initialize addr: req(:addr), handler: Handler.new
    @addr    = addr
    @handler = handler
  end

  def join
    thread.join
  end

  def start
    @thread = Thread.new { run_loop }
    wait_till_started
    self
  end

  def stop
    thread.exit.join
  end

  attr_reader :handler, :thread
  private     :handler, :thread

  private

  def handle input, client_addr
    handler.handle Message.new(input), client_addr
  rescue Message::UnknownType
    nil
  end
end end end
{'fraction_non_alphanumeric': 0.07561728395061729, 'fraction_numerical': 0.0, 'mean_word_length': 3.1044303797468356, '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': '6484151', 'n_tokens_mistral': 404, 'n_tokens_neox': 386, 'n_words': 122}