Sha256: 34fe8bd7ef81816188b6e278d93df18782b68aa4cc3870cb452c889f7f413c8c
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require_relative "base" module Wamp module Manager module Event # Registered Message Event class Registered < Base # Adding listener for invocation message def listen_event_name "registration_#{registration_id}" end def add_event_listener(handler) session.on(listen_event_name) do |invocation| details = {} details = { details: yield_method(invocation) } if invocation.details["receive_progress"] result = handler.call(*invocation.args, **invocation.kwargs, **details) message = Message::Yield.new(invocation.request_id, {}, result) session.transmit(message.payload) end end def yield_method(invocation) klass = Struct.new(:invocation, :session) do def progress(*args, **kwargs) message = Message::Yield.new(invocation.request_id, { progress: true }, *args, **kwargs) session.transmit(message.payload) end end klass.new(invocation, session) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
xconn-0.1.2 | lib/wamp/manager/event/registered.rb |
xconn-0.1.1 | lib/wamp/manager/event/registered.rb |
xconn-0.1.0 | lib/wamp/manager/event/registered.rb |