Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support livereload protocol version 7

  • Loading branch information...
commit eef517f0f36ccc890a6718f7983b9f4d757a105b 1 parent c481a8e
@tka tka authored
Showing with 22 additions and 7 deletions.
  1. +2 −2 src/compile_version.rb
  2. +20 −5 src/livereload.rb
View
4 src/compile_version.rb
@@ -1,5 +1,5 @@
module CompileVersion
- REVISION = 'a434ec766b'
- COMPILE_TIME = '201303180806'
+ REVISION = 'c481a8ee8c'
+ COMPILE_TIME = '201303180843'
UPDATE_URL = ''
end
View
25 src/livereload.rb
@@ -1,4 +1,7 @@
+require "singleton"
require 'em-websocket'
+require 'json'
+
module EventMachine
module WebSocket
class Connection
@@ -75,7 +78,7 @@ def start_websocket_server(options)
ws.onopen do
begin
puts "Browser connected.";
- ws.send "!!ver:#{1.6}";
+ #ws.send "!!ver:#{1.6}";
SimpleLivereload.instance.clients << ws
rescue
puts $!
@@ -84,6 +87,17 @@ def start_websocket_server(options)
end
ws.onmessage do |msg|
puts "Browser URL: #{msg}"
+ begin
+ msg = JSON.parse(msg)
+ if msg["command"]=='hello'
+ ws.send JSON.dump({
+ "command" => 'hello',
+ "protocols" => ['http://livereload.com/protocols/official-7'],
+ "serverName" => "Fire.app"
+ })
+ end
+ rescue
+ end
end
ws.onclose do
@@ -105,10 +119,11 @@ def alive?
end
def send_livereload_msg( base, relative )
- data = JSON.dump( ['refresh', { :path => URI.escape(File.join(base, relative)),
- :apply_js_live => true,
- :apply_css_live => true,
- :apply_images_live => true }] )
+ data = JSON.dump( {
+ :command => "reload",
+ :path => URI.escape(File.join(base, relative)),
+ :liveCSS => true,
+ } )
@clients.each do |ws|
EM::next_tick do
ws.send(data)
Please sign in to comment.
Something went wrong with that request. Please try again.