Class: Alondra::Connection
- Inherits:
-
Object
- Object
- Alondra::Connection
- Defined in:
- lib/alondra/connection.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#websocket ⇒ Object
readonly
Returns the value of attribute websocket.
Instance Method Summary collapse
- #destroy! ⇒ Object
-
#initialize(websocket, session = {}) ⇒ Connection
constructor
A new instance of Connection.
- #receive(event_or_message) ⇒ Object
Constructor Details
#initialize(websocket, session = {}) ⇒ Connection
Returns a new instance of Connection.
30 31 32 33 34 35 36 |
# File 'lib/alondra/connection.rb', line 30 def initialize(websocket, session = {}) @session = session.symbolize_keys @websocket = websocket @uuid = UUIDTools::UUID.random_create Connections[websocket] = self end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
28 29 30 |
# File 'lib/alondra/connection.rb', line 28 def channels @channels end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
27 28 29 |
# File 'lib/alondra/connection.rb', line 27 def session @session end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
25 26 27 |
# File 'lib/alondra/connection.rb', line 25 def uuid @uuid end |
#websocket ⇒ Object (readonly)
Returns the value of attribute websocket.
26 27 28 |
# File 'lib/alondra/connection.rb', line 26 def websocket @websocket end |
Instance Method Details
#destroy! ⇒ Object
47 48 49 50 |
# File 'lib/alondra/connection.rb', line 47 def destroy! channels.each { |c| c.unsubscribe self } Connections.delete self.websocket end |