Giter Club home page Giter Club logo

websockets-log-tail's Introduction

websockets-log-tail

Follow a stream from a server in an HTML5 compatible browser (like tailing a log file).

Status: beta

This project holds demonstration java source code that uses websockets to send a sample stream of 10 lines of text a second to a browser.

While viewing the web page scroll to the bottom happens automatically but can be paused by hitting the space bar. Auto scrolling is resumed by hitting the space bar again.

Run the demo

git clone https://github.com/davidmoten/websockets-log-tail.git
cd websockets-log-tail
mvn test jetty:run

Go to http://localhost:8080

or to view a tail of /var/log/syslog: http://localhost:8080/?tail=true.

Technical details

This demo has dependencies on RxJava 2.x, jetty-websocket and jetty-server artifacts and their dependencies. RxJava is a great addition to a streaming solution because it simplifies cancelling subscriptions and enables functional transformations (and all the other superb RxJava goodness like retries, timeouts, caching, multicast, and a heap more).

The code in this project is super simple and brief thanks to jetty libraries.

  • index.html - calls ViewerServlet as an html5 websocket service
  • web.xml - defines url for ViewerServlet
  • ViewerServlet - implements jetty WebSocketServlet.doWebSocketConnect() and returns a StreamWebSocket
  • StreamWebSocket - implements jetty WebSocket, starts and stops streaming to browser

websockets-log-tail's People

Contributors

davidmoten avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.