diff --git a/lib/wamp/message_handler/invocation.rb b/lib/wamp/message_handler/invocation.rb index 90e0ea3..a21930c 100644 --- a/lib/wamp/message_handler/invocation.rb +++ b/lib/wamp/message_handler/invocation.rb @@ -16,7 +16,10 @@ def alt_store_key end def invocation_response - Type::Invocation.new(args: message.args, kwargs: message.kwargs, details: message.details) + Type::Invocation.new(args: message.args, kwargs: message.kwargs, details: message.details).tap do |invocation| + invocation.connection = connection + invocation.request_id = message.request_id + end end private diff --git a/lib/wamp/message_handler/result.rb b/lib/wamp/message_handler/result.rb index 44b5cf1..d6d9065 100644 --- a/lib/wamp/message_handler/result.rb +++ b/lib/wamp/message_handler/result.rb @@ -6,7 +6,11 @@ module MessageHandler class Result < Base def handle validate_received_message - stored_data.fetch(:handler).call(response) + if message.details[:progress] + store[store_key].fetch(:handler).call(response) + else + stored_data.fetch(:handler).call(response) + end end def response diff --git a/lib/wamp/type/invocation.rb b/lib/wamp/type/invocation.rb index 5b3588c..969a9b5 100644 --- a/lib/wamp/type/invocation.rb +++ b/lib/wamp/type/invocation.rb @@ -4,6 +4,7 @@ module Wamp module Type # Invocation Type class Invocation + attr_writer :connection, :request_id attr_reader :args, :kwargs, :details def initialize(args: [], kwargs: {}, details: {}) @@ -11,6 +12,14 @@ def initialize(args: [], kwargs: {}, details: {}) @kwargs = kwargs @details = details end + + def progress(result) + @connection.transmit @connection.session.send_message(response(result)) + end + + def response(result) + Wampproto::Message::Yield.new(@request_id, result.details, *result.args, **result.kwargs) + end end end end diff --git a/lib/wamp/version.rb b/lib/wamp/version.rb index 0dd761c..c3a3a4b 100644 --- a/lib/wamp/version.rb +++ b/lib/wamp/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Wamp - VERSION = "0.1.0" + VERSION = "0.1.1" end diff --git a/wamp.gemspec b/wamp.gemspec index 88d120d..f59b3b3 100644 --- a/wamp.gemspec +++ b/wamp.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| spec.add_dependency "ed25519", "~> 1.3" spec.add_dependency "msgpack", "~> 1.7.2" spec.add_dependency "nio4r", "~> 2.7" - spec.add_dependency "wampproto", "~> 0.1.1" + spec.add_dependency "wampproto", "~> 0.1.2" spec.add_dependency "websocket-driver", "~> 0.7" spec.metadata["rubygems_mfa_required"] = "true" end