Class: Rack::Stream::Handlers::WebSocket
Overview
This handler uses delegates WebSocket requests to faye-websocket
Class Method Summary
collapse
Instance Method Summary
collapse
#chunk, #initialize
Class Method Details
.accepts?(app) ⇒ Boolean
6
7
8
|
# File 'lib/rack/stream/handlers/web_socket.rb', line 6
def self.accepts?(app)
::Faye::WebSocket.websocket?(app.env)
end
|
Instance Method Details
#close ⇒ Object
10
11
12
13
14
|
# File 'lib/rack/stream/handlers/web_socket.rb', line 10
def close
@body.callback {
@ws.close(@app.status)
}
end
|
#open ⇒ Object
16
17
18
19
20
21
|
# File 'lib/rack/stream/handlers/web_socket.rb', line 16
def open
@ws = ::Faye::WebSocket.new(@app.env)
@ws.onopen = lambda do |event|
@body.each {|c| @ws.send(c)}
end
end
|