@Target(value=TYPE) @Retention(value=RUNTIME) @Documented @Import(value={WebSocketConfig.class,WsSessionManager.class}) public @interface AutoConfigureWebsocket
app:
...
# websocket配置
websocket:
maxIdle: 60000 # 连接最大空闲时间,单位ms
allowedOrigins: # 允许的origin来源
- "*"
handlers:
- handlerClass: com.github.hetianyi.learn.demo.controller.MyMessageHandler # 消息处理类
endpoints: # websocket端点
- /ws
- /ws1
实现一个MessageHandler:
Copyright © 2022. All rights reserved.