class

Hwaro::Services::LiveReloadHandler

Inherits HTTP::Handler < Reference < Object

Constants

CSS_SWAP_HELLO = "hello:css"

Sent by the client script on connect to opt in to css: messages.

LIVE_RELOAD_PATH = "/__hwaro_livereload"
QUEUE_LIMIT = 32

How many outbound messages one client may fall behind by. Broadcast enqueues here instead of writing to the socket, so a tab that handshakes and then stops reading (suspended laptop, paused debugger, a hand-rolled client left open) can absorb this many messages before we give up on it. The watcher emits at most one message per rebuild, so a client this far behind is wedged, not merely slow.

Instance methods

call(context)
Source
notify_build_error(message : String)

Push a build-error message so connected browsers can render an overlay. The message is a single line error:<json> so the client side can split on the first colon and parse the rest; using JSON keeps the schema extensible (we may want to add file, line, etc. later) without ad-hoc string parsing.

Source
notify_css(paths : Array(String))

A rebuild changed only stylesheets: clients that opted in (see CSS_SWAP_HELLO) swap the <link rel="stylesheet">s whose path ends with one of paths (every same-origin one when paths is empty) without reloading; any other client reloads as before.

Source
notify_reload
Source