Class: Munge::Extra::Livereload::Server

Inherits:
Reel::Server::HTTP
  • Object
show all
Defined in:
lib/munge/extra/livereload/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(host = "127.0.0.1", port = 35729) ⇒ Server

Returns a new instance of Server.



5
6
7
8
9
10
# File 'lib/munge/extra/livereload/server.rb', line 5

def initialize(host = "127.0.0.1", port = 35729)
  super(host, port, &method(:on_connection))
  @update_client = UpdateClient.new(self)
  @messaging = Messaging.new
  @sockets = []
end

Instance Method Details

#notify_reload(changed_files) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/munge/extra/livereload/server.rb', line 12

def notify_reload(changed_files)
  @sockets.select! do |socket|
    begin
      changed_files.each do |file|
        socket << @messaging.reload(file)
      end

      true
    rescue Reel::SocketError
      false
    end
  end
end