Class: Wamp::Manager::Session
- Inherits:
-
Object
- Object
- Wamp::Manager::Session
- Extended by:
- Forwardable
- Defined in:
- lib/wamp/manager/session.rb
Overview
handles session
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
Instance Method Summary collapse
- #call(procedure, options = {}, *args, **kwargs, &block) ⇒ Object
- #create_request_id ⇒ Object
-
#initialize(connection) ⇒ Session
constructor
A new instance of Session.
- #on_message(message) ⇒ Object
- #publish(topic, options = {}, *args, **kwargs, &block) ⇒ Object
- #register(procedure, handler, options = {}, &block) ⇒ Object
- #send_protocol_violation(text, *args, **kwargs) ⇒ Object
- #subscribe(topic, handler, options = {}, &block) ⇒ Object
- #unregister(registration_id, &block) ⇒ Object
- #unsubscribe(subscription_id, &block) ⇒ Object
Constructor Details
#initialize(connection) ⇒ Session
Returns a new instance of Session.
13 14 15 |
# File 'lib/wamp/manager/session.rb', line 13 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
11 12 13 |
# File 'lib/wamp/manager/session.rb', line 11 def connection @connection end |
#session_id ⇒ Object
Returns the value of attribute session_id.
11 12 13 |
# File 'lib/wamp/manager/session.rb', line 11 def session_id @session_id end |
Instance Method Details
#call(procedure, options = {}, *args, **kwargs, &block) ⇒ Object
50 51 52 53 |
# File 'lib/wamp/manager/session.rb', line 50 def call(procedure, = {}, *args, **kwargs, &block) = Message::Call.new(next_request_id, , procedure, *args, **kwargs) Manager::Event::Call.new(, self).add_event_listener(&block) end |
#create_request_id ⇒ Object
70 71 72 |
# File 'lib/wamp/manager/session.rb', line 70 def create_request_id next_request_id end |
#on_message(message) ⇒ Object
65 66 67 68 |
# File 'lib/wamp/manager/session.rb', line 65 def () manager = Manager::Event.resolve(, self) manager.emit_event() end |
#publish(topic, options = {}, *args, **kwargs, &block) ⇒ Object
44 45 46 47 48 |
# File 'lib/wamp/manager/session.rb', line 44 def publish(topic, = {}, *args, **kwargs, &block) = .merge({ acknowledge: true }) if block_given? = Message::Publish.new(next_request_id, , topic, *args, **kwargs) Manager::Event::Publish.new(, self).add_event_listener(&block) end |
#register(procedure, handler, options = {}, &block) ⇒ Object
55 56 57 58 |
# File 'lib/wamp/manager/session.rb', line 55 def register(procedure, handler, = {}, &block) = Message::Register.new(next_request_id, , procedure) Manager::Event::Register.new(, self).add_event_listener(handler, &block) end |
#send_protocol_violation(text, *args, **kwargs) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/wamp/manager/session.rb', line 25 def send_protocol_violation(text, *args, **kwargs) = Message::Abort.new({ message: text }, "wamp.error.protocol_violation", *args, **kwargs) manager = Manager::Event::Abort.new(, self) connection.transmit(.payload) manager.emit_event() end |
#subscribe(topic, handler, options = {}, &block) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/wamp/manager/session.rb', line 32 def subscribe(topic, handler, = {}, &block) = Message::Subscribe.new(next_request_id, , topic) manager = Manager::Event::Subscribe.new(, self) manager.add_event_listener(handler, &block) manager.subscription end |
#unregister(registration_id, &block) ⇒ Object
60 61 62 63 |
# File 'lib/wamp/manager/session.rb', line 60 def unregister(registration_id, &block) = Message::Unregister.new(next_request_id, registration_id) Manager::Event::Unregister.new(, self).add_event_listener(&block) end |
#unsubscribe(subscription_id, &block) ⇒ Object
39 40 41 42 |
# File 'lib/wamp/manager/session.rb', line 39 def unsubscribe(subscription_id, &block) = Message::Unsubscribe.new(next_request_id, subscription_id) Subscription.new(, self, subscription_id).unsubscribe(&block) end |