Class: Rlyeh::Session
- Inherits:
-
Object
- Object
- Rlyeh::Session
- Extended by:
- Forwardable
- Includes:
- Celluloid, Logger
- Defined in:
- lib/rlyeh/session.rb
Instance Attribute Summary collapse
-
#connections ⇒ Object
readonly
Returns the value of attribute connections.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #attach(connection) ⇒ Object
- #close ⇒ Object
- #detach(connection) ⇒ Object
-
#initialize(id) ⇒ Session
constructor
A new instance of Session.
- #send_data(data) ⇒ Object
Methods included from Logger
Constructor Details
#initialize(id) ⇒ Session
Returns a new instance of Session.
15 16 17 18 19 |
# File 'lib/rlyeh/session.rb', line 15 def initialize(id) @id = id @connections = Set.new debug "Session started: #{@id}" end |
Instance Attribute Details
#connections ⇒ Object (readonly)
Returns the value of attribute connections.
12 13 14 |
# File 'lib/rlyeh/session.rb', line 12 def connections @connections end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/rlyeh/session.rb', line 12 def id @id end |
Instance Method Details
#attach(connection) ⇒ Object
25 26 27 28 |
# File 'lib/rlyeh/session.rb', line 25 def attach(connection) connection.attach self @connections.add connection end |
#close ⇒ Object
21 22 23 |
# File 'lib/rlyeh/session.rb', line 21 def close debug "Session closed: #{@id}" end |
#detach(connection) ⇒ Object
30 31 32 33 |
# File 'lib/rlyeh/session.rb', line 30 def detach(connection) @connections.delete connection connection.detach self end |
#send_data(data) ⇒ Object
35 36 37 38 39 |
# File 'lib/rlyeh/session.rb', line 35 def send_data(data) @connections.each do |connection| connection.send_data data, false end end |