Class: Wamp::Router::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/wamp/router/base.rb

Overview

Router

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



11
12
13
# File 'lib/wamp/router/base.rb', line 11

def initialize
  @realms = {}
end

Instance Attribute Details

#realmsObject (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

Raises:

  • (Wampproto::ValueError)


23
24
25
26
27
28
# File 'lib/wamp/router/base.rb', line 23

def attach_client(client)
  error_message = "cannot attach client to non-existent realm #{client.realm}"
  raise Wampproto::ValueError, error_message unless realms.include?(client.realm)

  realms[client.realm].attach_client(client)
end

#detach_client(client) ⇒ Object

Raises:

  • (Wampproto::ValueError)


30
31
32
33
34
35
# File 'lib/wamp/router/base.rb', line 30

def detach_client(client)
  error_message = "cannot attach client to non-existent realm #{client.realm}"
  raise Wampproto::ValueError, error_message unless realms.include?(client.realm)

  realms[client.realm].detach_client(client)
end

#receive_message(client, message) ⇒ Object

Raises:

  • (Wampproto::ValueError)


37
38
39
40
41
42
# File 'lib/wamp/router/base.rb', line 37

def receive_message(client, message)
  error_message = "cannot attach client to non-existent realm #{client.realm}"
  raise Wampproto::ValueError, error_message unless realms.include?(client.realm)

  realms[client.realm].receive_message(client.session_id, message)
end

#remove_realm(name) ⇒ Object



19
20
21
# File 'lib/wamp/router/base.rb', line 19

def remove_realm(name)
  realms.delete(name)
end