lib/ws-io.rb in ws-io-1.1.2 vs lib/ws-io.rb in ws-io-1.1.3
- old
+ new
@@ -28,11 +28,10 @@
begin
@server.run() do |ws|
if ws.path == "/"
ws.handshake()
WsIo.ws = ws
- ws.send("connected")
c.signal # ####
while data = ws.receive() #
WsIo.input(data) #
end #
else # ## ## ## ## ######## ######## ## ## ####
@@ -45,10 +44,11 @@
end #
end #
#
Thread.start do #
m.synchronize { c.wait(m) } # <###
+ @after_block.call if @after_block
loop do
if @ws
begin
@ws.send(escape(output))
rescue
@@ -80,21 +80,25 @@
unfake_io
stop_server
raise
end
- def after
- yield
+ def after(&block)
+ @after_block = block
self
end
def join
@server_thread.join if @server_thread
end
def open
+ js_paths = %w(jquery.min.js autoresize.jquery.js).map do |js|
+ 'file://localhost' + File.expand_path("../public/#{js}", __FILE__)
+ end
tempfile = Tempfile.open('ws-io')
- tempfile << ERB.new(File.read(File.expand_path('../index.html.erb', __FILE__))).result(binding)
+ template = File.read(File.expand_path('../public/index.html.erb', __FILE__))
+ tempfile << ERB.new(template, nil, '-').result(binding)
tempfile.flush
Launchy::Browser.run(tempfile.path)
self
end