!317 集成websocket功能

* add 增加 ruoyi-common-websocket 模块 支持token鉴权 支持分布式集群消息同步
This commit is contained in:
zendwang
2023-03-29 14:18:42 +00:00
committed by 疯狂的狮子Li
parent abca91c18f
commit 65ae5ab362
15 changed files with 571 additions and 0 deletions

View File

@ -94,6 +94,10 @@
<artifactId>ruoyi-common-tenant</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-websocket</artifactId>
</dependency>
<!-- 短信 用哪个导入哪个依赖 -->
<!-- <dependency>-->
<!-- <groupId>com.aliyun</groupId>-->

View File

@ -0,0 +1,33 @@
package com.ruoyi.demo.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.websocket.dto.WebSocketMessageDto;
import com.ruoyi.common.websocket.utils.WebSocketUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* WebSocket 演示案例
*
* @author zendwang
*/
@RequiredArgsConstructor
@RestController
@RequestMapping("/demo/websocket")
@Slf4j
public class WeSocketController {
/**
* 发布消息
*
* @param dto 发送内容
*/
@GetMapping("/send")
public R<Void> send(WebSocketMessageDto dto) throws InterruptedException {
WebSocketUtils.publishMessage(dto);
return R.ok("操作成功");
}
}