/conversational-websocket-server

Simple implementation of a websocket server which enables an adhoc communication with connected clients via command line.

Primary LanguageJava

Conversational Websocke Server

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.

Used Libraries

  • spring-boot-starter-web
  • spring-websocket
  • spring-shell-starter

Build & Run

Run through maven:

$ mvn spring-boot:run  

Build and run as standalone:

$ mvn clean package
...
$ java -jar cws.jar 

Commands

The following commands are implemented.

Clients

List all connected clients by session id.

clients ⏎

Broadcast

Send a message as broadcast to all connected clients.

broadcast 'hello to all' ⏎

Unicast

Send a message as unicast to a specific client.

unicast 0 'hello client 0' ⏎