Sha256: 221b26b141d6d504d0ace7157b932985eba15bc77df2767bd88fc8690b91eaf9

Contents?: true

Size: 725 Bytes

Versions: 1

Compression:

Stored size: 725 Bytes

Contents

module Kamerling class Handler
  UnknownInput = Class.new RuntimeError

  def initialize receiver: Receiver.new, registrar: Registrar.new
    @receiver, @registrar = receiver, registrar
  end

  def handle input, addr
    message = Message.new input
    case message.type
    when :RGST
      registrar.register addr: addr, client_uuid: message.client_uuid,
        project_uuid: message.project_uuid
    when :RSLT
      receiver.receive addr: addr, client_uuid: message.client_uuid,
        data: message.payload, task_uuid: message.task_uuid
    end
  rescue Message::UnknownType => exception
    raise UnknownInput, exception.message
  end

  attr_reader :receiver, :registrar
  private     :receiver, :registrar
end end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamerling-0.0.1 lib/kamerling/handler.rb