Spring-Boot / Websocket Example

It’s been a while!

Project for this post: https://github.com/mtrojahn/spring-boot-websocket

Recently I stumbled upon the need of using Websockets. I confess I know little about the subject and I hope this little tutorial can help you to get started. I’m making this post just because I tried to help here on StackOverflow and I thought I should just post it here as well.

pom.xml

Application.class (nothing special here)

WebSocketConfiguration.class

PingPongController.class

This is the main thing. For this example I added a scheduled method that will periodically broadcast a message to all clients and another method that will just respond if a client send a “/ping” command.

Now, for the client I have this simple script:

index.html

See you next time (and I hope I have more time to explain things).

You may also like...

Leave a Reply

%d bloggers like this: