Class: WAMP::Socket
- Inherits:
-
Object
- Object
- WAMP::Socket
- Defined in:
- lib/wamp/socket.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#prefixes ⇒ Object
Returns the value of attribute prefixes.
-
#topics ⇒ Object
Returns the value of attribute topics.
-
#websocket ⇒ Object
Returns the value of attribute websocket.
Instance Method Summary collapse
- #add_prefix(prefix, uri) ⇒ Object
- #add_topic(topic) ⇒ Object
-
#initialize(id, websocket) ⇒ Socket
constructor
A new instance of Socket.
- #remove_topic(topic) ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(id, websocket) ⇒ Socket
Returns a new instance of Socket.
7 8 9 10 11 12 13 14 |
# File 'lib/wamp/socket.rb', line 7 def initialize(id, websocket) @id = id @topics = [] @prefixes = {} @websocket = websocket end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/wamp/socket.rb', line 5 def id @id end |
#prefixes ⇒ Object
Returns the value of attribute prefixes.
5 6 7 |
# File 'lib/wamp/socket.rb', line 5 def prefixes @prefixes end |
#topics ⇒ Object
Returns the value of attribute topics.
5 6 7 |
# File 'lib/wamp/socket.rb', line 5 def topics @topics end |
#websocket ⇒ Object
Returns the value of attribute websocket.
5 6 7 |
# File 'lib/wamp/socket.rb', line 5 def websocket @websocket end |
Instance Method Details
#add_prefix(prefix, uri) ⇒ Object
24 25 26 |
# File 'lib/wamp/socket.rb', line 24 def add_prefix(prefix, uri) prefixes[prefix] = uri end |
#add_topic(topic) ⇒ Object
16 17 18 |
# File 'lib/wamp/socket.rb', line 16 def add_topic(topic) topics << topic unless topics.include? topic end |
#remove_topic(topic) ⇒ Object
20 21 22 |
# File 'lib/wamp/socket.rb', line 20 def remove_topic(topic) topics.delete(topic) end |
#to_json ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/wamp/socket.rb', line 28 def to_json { id: id, topics: topics, prefixes: prefixes }.to_json end |