Seed also integrates the Java API for WebSocket (JSR 356), allowing server and client endpoints to be injected. WebSocket support requires Java 7 and a compatible server to work.

Server endpoints

Server endpoints have to explicitly specify a SeedBaseEndpointConfigurator to be managed by Seed.

@ServerEndpoint(value = "/chat", configurator = BaseServerEndpointConfigurator.class)
public class ChatEndpoint {

    private Logger logger;

    EchoService echoService;

    public void onOpen(Session session) {
        logger.info("Connected ... " + session.getId());

    public void message(String message, 
                        Session client) throws IOException, EncodeException {
        for (Session peer : client.getOpenSessions()) {

    public void onClose(Session session, CloseReason closeReason) {
        logger.info(String.format("Session %s close because of %s", 
            session.getId(), closeReason));

    public void onError(Session session, Throwable t) {
        logger.error(t.getMessage(), t);


In this example, the endpoint receives a message and then broadcast it to all clients.

Client endpoints

Client endpoints have to explicitly specify a SeedClientEndpointConfigurator to be managed by Seed.

@ClientEndpoint(configurator = SeedClientEndpointConfigurator.class)
public class ChatClientEndpoint1 {
    public static final String TEXT = "Client1 joins";
    public static CountDownLatch latch;
    public static String response;

    public void onOpen(Session session) {
        try {
        } catch (IOException ioe) {

    public void processMessage(String message) {
        response = message;

On this page