Sha256: 927c778558e978cf2365073f92017df55604f5dbfd88ae861b0064793d679172

Contents?: true

Size: 452 Bytes

Versions: 1

Compression:

Stored size: 452 Bytes

Contents

require 'async/websocket'

class Upgrade
	def initialize(app)
		@app = app
	end
	
	def call(env)
		if Async::WebSocket?(env)
			Async::WebSocket.open(env) do |connection|
				read, write = IO.pipe
				
				Process.spawn("ls -lah", :out => write)
				write.close
				
				read.each_line do |line|
					connection.text(line)
				end
				
				connection.close
			end
		else
			@app.call(env)
		end
	end
end

use Upgrade

run lambda {|env| [404, {}, []]}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
async-websocket-0.2.0 spec/async/websocket/connection_spec.ru