Class: Wamp::Router::Base
- Inherits:
-
Object
- Object
- Wamp::Router::Base
- Defined in:
- lib/wamp/router/base.rb
Overview
Router
Instance Attribute Summary collapse
-
#realms ⇒ Object
readonly
Returns the value of attribute realms.
Instance Method Summary collapse
- #add_realm(name) ⇒ Object
- #attach_client(client) ⇒ Object
- #detach_client(client) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #receive_message(client, message) ⇒ Object
- #remove_realm(name) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/wamp/router/base.rb', line 11 def initialize @realms = {} end |
Instance Attribute Details
#realms ⇒ Object (readonly)
Returns the value of attribute realms.
9 10 11 |
# File 'lib/wamp/router/base.rb', line 9 def realms @realms end |
Instance Method Details
#add_realm(name) ⇒ Object
15 16 17 |
# File 'lib/wamp/router/base.rb', line 15 def add_realm(name) realms[name] = Realm.new(name) end |
#attach_client(client) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/wamp/router/base.rb', line 23 def attach_client(client) = "cannot attach client to non-existent realm #{client.realm}" raise Wampproto::ValueError, unless realms.include?(client.realm) realms[client.realm].attach_client(client) end |
#detach_client(client) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/wamp/router/base.rb', line 30 def detach_client(client) = "cannot attach client to non-existent realm #{client.realm}" raise Wampproto::ValueError, unless realms.include?(client.realm) realms[client.realm].detach_client(client) end |
#receive_message(client, message) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/wamp/router/base.rb', line 37 def (client, ) = "cannot attach client to non-existent realm #{client.realm}" raise Wampproto::ValueError, unless realms.include?(client.realm) realms[client.realm].(client.session_id, ) end |
#remove_realm(name) ⇒ Object
19 20 21 |
# File 'lib/wamp/router/base.rb', line 19 def remove_realm(name) realms.delete(name) end |