Class: ReverseTunnel::Client::LocalConnections
- Inherits:
-
Object
- Object
- ReverseTunnel::Client::LocalConnections
- Defined in:
- lib/reverse-tunnel/client.rb
Instance Attribute Summary collapse
-
#connections ⇒ Object
readonly
Returns the value of attribute connections.
Instance Method Summary collapse
- #as_json ⇒ Object
- #bufferize(session_id, data) ⇒ Object
- #buffers ⇒ Object
- #close_all ⇒ Object
- #delete(connection) ⇒ Object
- #find(session_id) ⇒ Object
-
#initialize ⇒ LocalConnections
constructor
A new instance of LocalConnections.
- #push(connection) ⇒ Object (also: #<<)
Constructor Details
#initialize ⇒ LocalConnections
Returns a new instance of LocalConnections.
138 139 140 |
# File 'lib/reverse-tunnel/client.rb', line 138 def initialize @connections = [] end |
Instance Attribute Details
#connections ⇒ Object (readonly)
Returns the value of attribute connections.
136 137 138 |
# File 'lib/reverse-tunnel/client.rb', line 136 def connections @connections end |
Instance Method Details
#as_json ⇒ Object
175 176 177 |
# File 'lib/reverse-tunnel/client.rb', line 175 def as_json connections.map(&:as_json) end |
#bufferize(session_id, data) ⇒ Object
162 163 164 165 |
# File 'lib/reverse-tunnel/client.rb', line 162 def bufferize(session_id, data) ReverseTunnel.logger.debug { "Push buffer for #{session_id}" } buffers[session_id] << data end |
#buffers ⇒ Object
158 159 160 |
# File 'lib/reverse-tunnel/client.rb', line 158 def buffers @buffers ||= Hash.new { |h,k| h[k] = [] } end |
#close_all ⇒ Object
171 172 173 |
# File 'lib/reverse-tunnel/client.rb', line 171 def close_all connections.each(&:close_connection) end |
#delete(connection) ⇒ Object
167 168 169 |
# File 'lib/reverse-tunnel/client.rb', line 167 def delete(connection) connections.delete connection end |
#find(session_id) ⇒ Object
142 143 144 |
# File 'lib/reverse-tunnel/client.rb', line 142 def find(session_id) connections.find { |c| c.session_id == session_id } end |
#push(connection) ⇒ Object Also known as: <<
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/reverse-tunnel/client.rb', line 146 def push(connection) connections << connection session_id = connection.session_id ReverseTunnel.logger.debug { "Clear buffer for #{session_id}" } (buffers.delete(session_id) or []).each do |data| connection.send_data data end end |