<commit_before>Webbit - A Java event based WebSocket and HTTP server
=====================================================

Getting it
-----------

Warning: Webbit has not had a stable release yet - the API changes regularly.

    git clone git://github.com/joewalnes/webbit.git
    cd webbit
    make

You will need to add build/webbit.jar and lib/netty-3.2.3.Final.jar (its only dependency) to your classpath.

Quick start
-----------

Start a web server on port 8080 and serve some static files:

    WebServer webServer = WebServers.createWebServer(8080)
      .add(new StaticFileHandler("/path/to/files"))
      .start();

That was easy.

Now let's build a WebSocketHandler.

    public class HelloWebSockets implements WebSocketHandler {
    
      int connectionCount;
      
      public void onOpen(WebSocketConnection connection) {
        connection.send("Hello! There are " + connectionCount + " other connections active");
        connectionCount++;
      }
      
      public void onClose(WebSocketConnection connection) {
        connectionCount--;
      }
      
      public void onMessage(WebSocketConnection connection, String message) {
        connection.send(message.toUpperCase()); // echo back message in upper case
      }
    
      public static void main(String args) {
        WebServer webServer = WebServers.createWebServer(8080)
          .add("/hellowebsocket", new HelloWebSockets())
          .add(new StaticFileHandler("/path/to/files"))
          .start();
      }
    }
    
Look in the examples directory for a full chat application.<commit_msg>Added link to Jay's introduction.<commit_after>Webbit - A Java event based WebSocket and HTTP server
=====================================================

Getting it
-----------

Warning: Webbit has not had a stable release yet - the API changes regularly.

    git clone git://github.com/joewalnes/webbit.git
    cd webbit
    make

You will need to add build/webbit.jar and lib/netty-3.2.3.Final.jar (its only dependency) to your classpath.

Quick start
-----------

Start a web server on port 8080 and serve some static files:

    WebServer webServer = WebServers.createWebServer(8080)
      .add(new StaticFileHandler("/path/to/files"))
      .start();

That was easy.

Now let's build a WebSocketHandler.

    public class HelloWebSockets implements WebSocketHandler {
    
      int connectionCount;
      
      public void onOpen(WebSocketConnection connection) {
        connection.send("Hello! There are " + connectionCount + " other connections active");
        connectionCount++;
      }
      
      public void onClose(WebSocketConnection connection) {
        connectionCount--;
      }
      
      public void onMessage(WebSocketConnection connection, String message) {
        connection.send(message.toUpperCase()); // echo back message in upper case
      }
    
      public static void main(String args) {
        WebServer webServer = WebServers.createWebServer(8080)
          .add("/hellowebsocket", new HelloWebSockets())
          .add(new StaticFileHandler("/path/to/files"))
          .start();
      }
    }
    
Look in the examples directory for a full chat application.

More
-----------

+   <NAME> has written a WebSockets with Clojure introduction that uses Webbit: http://blog.jayfields.com/2011/02/clojure-web-socket-introduction.html
{'fraction_non_alphanumeric': 0.12529761904761905, 'fraction_numerical': 0.010714285714285714, 'mean_word_length': 2.7553072625698323, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4378179', 'n_tokens_mistral': 920, 'n_tokens_neox': 864, 'n_words': 282}