Sha256: e300da79dcaedab58b1551162f87166104354aeea1dcf7d05725f6a7f4a21289
Contents?: true
Size: 1015 Bytes
Versions: 1
Compression:
Stored size: 1015 Bytes
Contents
require "nio/websocket/raw_adapter" module NIO module WebSocket class Adapter < RawAdapter def initialize(io, driver, options) @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.message}" close :driver end super io, options end attr_reader :driver def teardown driver.force_state :closed driver.emit :io_error @driver = nil # circular reference super end def close(from = nil) driver.close if from.nil? && !closing super() end def read super do |data| driver.parse data end end end end end class ::WebSocket::Driver def force_state(newstate) @ready_state = STATES.index newstate end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nio4r-websocket-0.7.0 | lib/nio/websocket/adapter.rb |