Sha256: 3f1b9698dcd9cbe48f9c49317fb3fe710cc6e69828bdc6a27974cb90b2c455a8

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

# frozen_string_literal: true

module Wamp
  module MessageHandler
    # Call
    class Invocation < Base
      def handle
        connection.session.receive_message(message)
        data = store.fetch(alt_store_key)

        send_yield_message data.fetch(:handler)
      end

      def alt_store_key
        "registration_#{message.registration_id}"
      end

      def invocation_response
        Type::Invocation.new(args: message.args, kwargs: message.kwargs, details: message.details)
      end

      private

      def send_yield_message(handler)
        result = handler.call(invocation_response)
        yield_message = if result.instance_of?(Type::Result)
          Wampproto::Message::Yield.new(message.request_id, result.details, *result.args, **result.kwargs)
        else
          Wampproto::Message::Yield.new(message.request_id, {}, result)
        end
        send_serialized yield_message
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xconn-0.1.0 lib/wamp/message_handler/invocation.rb