Starts a websocket server (JSR-356) and command line interface to communicate with connected clients.
The server listens by default on port 8080 but might be changed via Spring profile or arguments.
The default WS endpoint is /api/ws/
As a test client Telsocket might be used.
- spring-boot-starter-web
- spring-websocket
- spring-shell-starter
Run through maven:
$ mvn spring-boot:run
Build and run as standalone:
$ mvn clean package
...
$ java -jar cws.jar
The following commands are implemented.
List all connected clients by session id.
clients ⏎
Send a message as broadcast to all connected clients.
broadcast 'hello to all' ⏎
Send a message as unicast to a specific client.
unicast 0 'hello client 0' ⏎