Class: Wamp::Manager::Event::Subscribe

Inherits:
Base
  • Object
show all
Defined in:
lib/wamp/manager/event/subscribe.rb

Overview

Subscribe Message Event

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods inherited from Base

#emit_event, #emit_event_name, #error?, #initialize, #transmit

Constructor Details

This class inherits a constructor from Wamp::Manager::Event::Base

Instance Method Details

#add_event_listener(listener, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/wamp/manager/event/subscribe.rb', line 15

def add_event_listener(listener, &block)
  session.on(listen_event_name) do |subscribed, error|
    subscription.subscription_id = subscribed.subscription_id if subscribed

    session.off(listen_event_name)
    block.call(subscribed, error) if block_given?
    add_subscribed_event_listner(subscribed, listener)
  end
  session.transmit(payload)
end

#listen_event_nameObject



26
27
28
# File 'lib/wamp/manager/event/subscribe.rb', line 26

def listen_event_name
  "request_#{request_id}"
end

#subscriptionObject



11
12
13
# File 'lib/wamp/manager/event/subscribe.rb', line 11

def subscription
  @subscription ||= Subscription.new(__getobj__, session)
end