Sha256: ec8894f6d09c51e9be0a7a75a44583eee88ea9406e9d24c04c4e1db591aae2ad

Contents?: true

Size: 525 Bytes

Versions: 2

Compression:

Stored size: 525 Bytes

Contents

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 input, client_addr
  rescue Handler::UnknownInput
  end
end end end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kamerling-0.0.2 lib/kamerling/server/sock.rb
kamerling-0.0.1 lib/kamerling/server/sock.rb