Class: Wamp::Router::Realm
- Inherits:
-
Object
- Object
- Wamp::Router::Realm
- Defined in:
- lib/wamp/router/realm.rb
Overview
Realm
Constant Summary collapse
- DEALER_MESSAGES =
[ Wampproto::Message::Call, Wampproto::Message::Yield, Wampproto::Message::Register, Wampproto::Message::Unregister ].freeze
- BROKER_MESSAGES =
[ Wampproto::Message::Publish, Wampproto::Message::Subscribe, Wampproto::Message::Unsubscribe ].freeze
- GOODBYE_MESSAGE =
Wampproto::Message::Goodbye
Instance Attribute Summary collapse
-
#broker ⇒ Object
readonly
Returns the value of attribute broker.
-
#clients ⇒ Object
readonly
Returns the value of attribute clients.
-
#dealer ⇒ Object
readonly
Returns the value of attribute dealer.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #attach_client(client) ⇒ Object
- #clear ⇒ Object
- #detach_client(client) ⇒ Object
-
#initialize(name) ⇒ Realm
constructor
A new instance of Realm.
- #receive_message(session_id, message) ⇒ Object
Constructor Details
#initialize(name) ⇒ Realm
Returns a new instance of Realm.
24 25 26 27 28 29 |
# File 'lib/wamp/router/realm.rb', line 24 def initialize(name) @name = name @broker = Wampproto::Broker.new(id_gen) @dealer = Wampproto::Dealer.new(id_gen) @clients = {} end |
Instance Attribute Details
#broker ⇒ Object (readonly)
Returns the value of attribute broker.
7 8 9 |
# File 'lib/wamp/router/realm.rb', line 7 def broker @broker end |
#clients ⇒ Object (readonly)
Returns the value of attribute clients.
7 8 9 |
# File 'lib/wamp/router/realm.rb', line 7 def clients @clients end |
#dealer ⇒ Object (readonly)
Returns the value of attribute dealer.
7 8 9 |
# File 'lib/wamp/router/realm.rb', line 7 def dealer @dealer end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/wamp/router/realm.rb', line 7 def name @name end |
Instance Method Details
#attach_client(client) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/wamp/router/realm.rb', line 31 def attach_client(client) session_id = client.session_id session_details = client.acceptor.session_details clients[session_id] = client broker.add_session(session_details) dealer.add_session(session_details) end |
#clear ⇒ Object
44 45 46 |
# File 'lib/wamp/router/realm.rb', line 44 def clear clients.each { |client| remove_client(client.session_id) } end |
#detach_client(client) ⇒ Object
40 41 42 |
# File 'lib/wamp/router/realm.rb', line 40 def detach_client(client) remove_client(client.session_id) end |
#receive_message(session_id, message) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/wamp/router/realm.rb', line 48 def (session_id, ) case when *DEALER_MESSAGES then handle_dealer(session_id, ) when *BROKER_MESSAGES then handle_broker(session_id, ) when GOODBYE_MESSAGE then handle_goodbye(session_id, ) end end |