Object
# File lib/em-websocket/handler.rb, line 4 def self.klass_factory(version) case version when 75 Handler75 when 76 Handler76 when 1..3 # We'll use handler03 - I believe they're all compatible Handler03 when 5 Handler05 when 6 Handler06 when 7 Handler07 when 8 # drafts 9, 10, 11 and 12 should never change the version # number as they are all the same as version 08. Handler08 when 13 # drafts 13 to 17 all identify as version 13 as they are # only minor changes or text changes. Handler13 else # According to spec should abort the connection raise HandshakeError, "Protocol version #{version} not supported" end end
# File lib/em-websocket/handler.rb, line 52 def close_websocket(code, body) # Implemented in subclass end
This corresponds to “Fail the WebSocket Connection” in the spec.
# File lib/em-websocket/handler.rb, line 66 def fail_websocket(e) debug [:error, e] close_websocket(e.code, e.message) @connection.close_connection_after_writing @connection.trigger_on_error(e) end
# File lib/em-websocket/handler.rb, line 86 def ping # Overridden in subclass false end
# File lib/em-websocket/handler.rb, line 91 def pingable? # Also Overridden false end
# File lib/em-websocket/handler.rb, line 45 def receive_data(data) @data << data process_data rescue WSProtocolError => e fail_websocket(e) end
Used to avoid un-acked and unclosed remaining open indefinitely
# File lib/em-websocket/handler.rb, line 57 def start_close_timeout @close_timer = EM::Timer.new(@connection.close_timeout) { @connection.close_connection e = WSProtocolError.new("Close handshake un-acked after #{@connection.close_timeout}s, closing tcp connection") @connection.trigger_on_error(e) } end
Generated with the Darkfish Rdoc Generator 2.