Skip to content

What is the Bristleback Server_0.2.1

bristleback edited this page May 19, 2013 · 2 revisions

What is the WebSockets protocol?

Creation of web applications demanding bidirectional communication between client and server using traditional HTTP request used to be a very difficult and time consuming task. The Websocket protocol was found in order to provide efficient, bidirectional communication using single TCP connection. Websocket facilitates the implementation of web application, such as: games, real time multi-users applications, stock market related applications, etc. Originally, it was introduced as a part of HTML5 standard. First Internet Draft was released in january 2009. In 2010, an article appeared, including allegations of Websocket security. Temporarily, Websocket support was disabled in some web browsers. However, the protocol was still evolving. In Hybi-05 Draft, security issues were finally fixed. Currently, almost all modern browsers support WebSockets protocol.

WebSockets have several advanteges and potential use cases. Because of its nature, communication using WebSockets uses less resources than using traditional HTTP techniques. They are bidirectional, which allows server to notify client about events with great accuracy.

"HTML5 Web Sockets can provide a 500:1 or — depending on the size of the HTTP headers — even a 1000:1 reduction in unnecessary HTTP header traffic and 3:1 reduction in latency." - WebSocket.org

Using WebSockets, you can save real amount of money through faster access to information and lower costs of server maintenance. Together with other cool HTML5 features, fancy online games can be written without using Flash (Quake II using WebSockets). In addition, we believe that WebSockets create an opportunity for entirely new ideas and types of applications.

What was the Bristleback Plugin?

First idea of creating new WebSockets implementation was born in October 2010. Initially, Bristleback was a plugin for JWebsocket framework. The project was hosted on Google code. At that time, there was very few ready to use solutions, so we decided to adapt some techniques used in modern web frameworks in WebSockets environment. From its start, Bristleback has one big goal:

Creating WebSockets applications should be at least as fast as creating traditional web applications.

As the JWebsocket plugin, Bristleback allowed user to define actions in separate classes, bind token payload into Java classes and serialize Java classes into tokens. It also had a mechanism for sending messages in a threadsafe way.

Using JWebsocket quickly became a bottleneck in further Bristleback development process. That's why we finally decided to rewrite whole project and become a full WebSockets server.

What is the Bristleback Server?

Today Bristleback is fully functional framework, using several external WebSockets implementations, which can be chosen by application creator. Currently we support Jetty, Netty and Tomcat as WebSockets engines. Using Bristleback, user can avoid low level protocol details and focus on his business logic. Yet, while being high productivity framework, Bristleback still offers high performance results, which is achieved by caching meta information and using stable external WebSockets protocol libraries.

Only few minutes are needed to build and run your first Bristleback application. Bristleback can be found in central Maven repository:

    <dependency>
      <groupId>pl.bristleback</groupid>
      <artifactId>bristleServer</artifactid>
      <version>0.2.1</version>
    </dependency>

Also, we prepared special archetype for web applications that can be found here. More information about using archetypes and creating first Bristleback application can be found on our wiki pages.

Using Bristleback action classes is fast, fun and should look familiar to all web developers:

    @ActionClass
    public class ClientNotificationUpdateAction {
    
      @Action
      public UserStatus previewEditedStatus(FacebookUser user, UserStatus status) {
        removeBadWords(status);
        return status;
      }
    }