netty-livereload

Livereload protocol implementation based on Netty

License

License

Categories

Categories

Net Netty Networking
GroupId

GroupId

com.github.alexvictoor
ArtifactId

ArtifactId

netty-livereload
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

netty-livereload
Livereload protocol implementation based on Netty
Project URL

Project URL

https://github.com/alexvictoor/netty-livereload
Source Code Management

Source Code Management

https://github.com/alexvictoor/netty-livereload

Download netty-livereload

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.alexvictoor/netty-livereload/ -->
<dependency>
    <groupId>com.github.alexvictoor</groupId>
    <artifactId>netty-livereload</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.alexvictoor/netty-livereload/
implementation 'com.github.alexvictoor:netty-livereload:0.1'
// https://jarcasting.com/artifacts/com.github.alexvictoor/netty-livereload/
implementation ("com.github.alexvictoor:netty-livereload:0.1")
'com.github.alexvictoor:netty-livereload:jar:0.1'
<dependency org="com.github.alexvictoor" name="netty-livereload" rev="0.1">
  <artifact name="netty-livereload" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.alexvictoor', module='netty-livereload', version='0.1')
)
libraryDependencies += "com.github.alexvictoor" % "netty-livereload" % "0.1"
[com.github.alexvictoor/netty-livereload "0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
io.netty : netty-transport jar 4.0.24.Final
io.netty : netty-codec-http jar 4.0.24.Final
org.slf4j : slf4j-api jar 1.6.4

test (4)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.1.2
junit : junit jar 4.11
org.assertj : assertj-core jar 1.7.0
com.jayway.awaitility : awaitility jar 1.6.2

Project Modules

There are no modules declared in this project.

Build Status

netty-livereload

Livereload protocol implementation based on Netty websocket implementation.
The goal of this project is to provide a livereload Java implementation as lighweight as possible .
It is strongly inspired by livereload-jvm which is based on Jetty websockets.

Livereload in a nutshell

Livereload is a productivity tool for web developers. During web development, it refreshs the browser each time a file has been changed on the server side such as a CSS stylesheet or an HTML document.
Under the cover, livereload relies on a websocket connection between the browser and the server. On the browser side, a javascript code (from livereload.js) opens a connection with a livereload server. Once the connection is established, commands can be exchanged between the server and the browser. On the server, a process watchs the filesystem for changes on web files (i.e. html, css, js, ...). When a file has been changed on the server, a command is send to the browser. This command once processed on the browser side generates a refresh of the current page.

How to enable reload in the browser

On the browser side the easiest way to include livereload.js into your application is to use a browser plugin. However it is not always possible to do so. If your application runs on a mobile device, on internet explorer or anywhere else where adding a browser extention is not an option, the fastest and more reliable way to include livereload.js is to use the following code fragment:

<script>document.write('<script src="http://'
    + (location.host || 'localhost').split(':')[0]
    + ':35729/livereload.js"></'
    + 'script>')</script>

Snipset taken from the livereload-js website

How to start netty-livereload from the CLI

The simplest way to start a livereload server from the command line is to use the "all in one" jar as below:

java -jar netty-livereload-0.1-allinone.jar PATH

PATH being the path to the folder containing your web files.
This "all in one" jar is available for download from maven central

How to embed the livereload server in your application

First you need to add a netty-livereload dependency to your project. Below a maven XML fragment to add in the dependencies section:

<dependency>
  <groupId>com.github.alexvictoor</groupId>
  <artifactId>netty-livereload</artifactId>
  <version>0.1</version>
</dependency>

Then you just need to create a WebSocketServer instance providing the path to your web files as a String. Port is optionnal, default value being 35729, which is the value specified in the livereload protocol specification.
Then you just need to start the server. Below a code example:

String rootFolder = "...";
WebSocketServer server = new WebSocketServer(rootFolder);
server.start();

Versions

Version
0.1