I wrote an instant chat tool using the stomp framework

WebSocket technology allows the server to actively push information to the client. It does not have to be like the Http protocol that the client must initiate a request to the server if it wants to obtain server data.

WebSocket is a full-duplex protocol, similar to Socket communication, both parties can send data to the other party at any time. Suitable for instant messaging.

This time I plan to use the stomp (based on WebSocket) framework to implement an instant messaging tool similar to QQ. The function is relatively simple, but there is no problem with the main function. Interested children's shoes can be modified.

Code combat

Import the stomp framework

Project catalog

WebSocketConfig

GlobalConsts

GreetingController

WebSocketEventListener

ClientMessage

ServerMessage

DemoWebSocketClient

Start class DemoWebSocketServer

Front-end code

Show results

Project source code address:

https://github.com/lvshen9/demo/tree/lvshen-dev/src/main/java/com/lvshen/demo/kafka/socket

 

Guess you like

Origin blog.csdn.net/wujialv/article/details/110369162