Class: NIO::WebSocket::Adapter
- Inherits:
-
RawAdapter
- Object
- RawAdapter
- NIO::WebSocket::Adapter
- Defined in:
- lib/nio/websocket/adapter.rb,
lib/nio/websocket/adapter/proxy.rb,
lib/nio/websocket/adapter/client.rb,
lib/nio/websocket/adapter/server.rb
Defined Under Namespace
Classes: Client, Proxy, ProxyAdapter, Server
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
Attributes inherited from RawAdapter
#closing, #inner, #monitor, #options
Instance Method Summary collapse
- #close(from = nil) ⇒ Object
-
#initialize(io, driver, options) ⇒ Adapter
constructor
A new instance of Adapter.
- #read ⇒ Object
- #teardown ⇒ Object
Methods inherited from RawAdapter
#add_to_reactor, #pump_buffer, #write
Constructor Details
#initialize(io, driver, options) ⇒ Adapter
Returns a new instance of Adapter.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nio/websocket/adapter.rb', line 6 def initialize(io, driver, ) @driver = driver driver.on :close do |ev| WebSocket.logger.info "Driver initiated #{inner} close (code #{ev.code}): #{ev.reason}" close :driver end driver.on :error do |ev| WebSocket.logger.error "Driver reports error on #{inner}: #{ev.}" close :driver end super io, end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
20 21 22 |
# File 'lib/nio/websocket/adapter.rb', line 20 def driver @driver end |
Instance Method Details
#close(from = nil) ⇒ Object
29 30 31 32 |
# File 'lib/nio/websocket/adapter.rb', line 29 def close(from = nil) driver.close if from.nil? && !closing super() end |
#read ⇒ Object
34 35 36 37 38 |
# File 'lib/nio/websocket/adapter.rb', line 34 def read super do |data| driver.parse data end end |
#teardown ⇒ Object
22 23 24 25 26 27 |
# File 'lib/nio/websocket/adapter.rb', line 22 def teardown driver.force_state :closed driver.emit :io_error @driver = nil # circular reference super end |