Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Web-socket server library which gives an opportunity to build web-socket services using annotation configuration. Inspired by Spring annotation configuration.
Java
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
pom.xml

README.md

websocket-service

Web-socket server library which gives an opportunity to build web-socket services using annotation configuration. Inspired by Spring annotation configuration style. Thus WebSocket protocol is in draft state now, I created wrapper layer between servlet and socket service. Currently library has wrappers for Jetty and Grizzly implementation.

Features

  • Default message parser is json message parser. Uses Jackson Processor.
  • Minimal configuration of servlet.

TODO

  • Maven repo for this library, currently you have to build local maven dependency.
  • More wrappers to support more implementation until there will be leading implementation on protocol release-time.
  • Normal, human-readable documentation, javadoc.

Example

See src/examples/chat-controller.

Code

Here is code from ChatController.java w/o any description. Simple configuration of chat application:

@WebSocketController
public class ChatController {

    @WebSocketRequest("/chat/online")
    public static void chatOnline(@Param String name, @Handler WebSocketHandler handler) {
        handler.getService().broadcast(new ManOnline(name), null);
    }

    @WebSocketRequest("/chat/offline")
    public static void chatOffline(@Param String name, @Handler WebSocketHandler handler) {
        handler.getService().broadcast(new ManOffline(name), null);
    }

    @WebSocketRequest("/chat/message")
    public static void chatMessage(@Param String name, @Param String message, @Handler WebSocketHandler handler) {
        handler.getService().broadcast(new ChatMessage(name, message), handler);
    }
}
Something went wrong with that request. Please try again.