Skip to content

Commit

Permalink
Merge pull request #18 from xconnio/progressive_call
Browse files Browse the repository at this point in the history
Update wampproto to 0.1.2 with concurrent call fix and add progressiv…
  • Loading branch information
rubyonrails3 authored May 31, 2024
2 parents 14e4209 + f1660f9 commit 5a86b21
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/wamp/message_handler/invocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/wamp/message_handler/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions lib/wamp/type/invocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ module Wamp
module Type
# Invocation Type
class Invocation
attr_writer :connection, :request_id
attr_reader :args, :kwargs, :details

def initialize(args: [], kwargs: {}, details: {})
@args = args
@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
2 changes: 1 addition & 1 deletion lib/wamp/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Wamp
VERSION = "0.1.0"
VERSION = "0.1.1"
end
2 changes: 1 addition & 1 deletion wamp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5a86b21

Please sign in to comment.