Skip to main content

dawdler-boot-web-undertow-websocket

Module Introduction​

WebSocket module support for the undertow container (split out of dawdler-boot-web-undertow).

1. Usage​

Add the following to pom.xml:

<dependencies>
<dependency>
<groupId>club.dawdler</groupId>
<artifactId>dawdler-boot-web-undertow-websocket</artifactId>
</dependency>
</dependencies>

2. Usage example​

Create a WebSocketServer class and configure its package in component-package-paths of dawdler-boot-web.


@ServerEndpoint(value = "/websocket", configurator = HttpSessionConfigurator.class)
public class WebSocketServer {
@OnOpen
public void onOpen(Session session, EndpointConfig config) throws IOException {
System.out.println("open");
}

@OnMessage
public void onMessage(String message, Session session) throws IOException {
System.out.println(message);
}

@OnClose
public void onClose(Session session) {
System.out.println("close");
}

@OnError
public void onError(Throwable error) {
System.out.println(error.getMessage());
}

}