Class: WAMP::Topic
- Inherits:
-
Object
- Object
- WAMP::Topic
- Defined in:
- lib/wamp/topic.rb
Instance Attribute Summary collapse
-
#clients ⇒ Object
Returns the value of attribute clients.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #add_client(client) ⇒ Object
-
#initialize(uri) ⇒ Topic
constructor
A new instance of Topic.
- #publish(client, protocol, payload, excluded, included) ⇒ Object
- #remove_client(client) ⇒ Object
Constructor Details
#initialize(uri) ⇒ Topic
Returns a new instance of Topic.
5 6 7 8 |
# File 'lib/wamp/topic.rb', line 5 def initialize(uri) @uri = uri @clients = [] end |
Instance Attribute Details
#clients ⇒ Object
Returns the value of attribute clients.
3 4 5 |
# File 'lib/wamp/topic.rb', line 3 def clients @clients end |
#uri ⇒ Object
Returns the value of attribute uri.
3 4 5 |
# File 'lib/wamp/topic.rb', line 3 def uri @uri end |
Instance Method Details
#add_client(client) ⇒ Object
10 11 12 |
# File 'lib/wamp/topic.rb', line 10 def add_client(client) clients << client unless clients.include? client end |
#publish(client, protocol, payload, excluded, included) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wamp/topic.rb', line 18 def publish(client, protocol, payload, excluded, included) rec_clients = clients.dup if excluded == true excluded = [client.id] elsif excluded == false || excluded.nil? excluded = [] end rec_clients.delete_if { |c| excluded.include? c.id } if included rec_clients.delete_if { |c| !included.include?(c.id) } end rec_clients.each do |c| c.websocket.send protocol.event(self.uri, payload) end end |
#remove_client(client) ⇒ Object
14 15 16 |
# File 'lib/wamp/topic.rb', line 14 def remove_client(client) clients.delete client end |