mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
!317 集成websocket功能
* add 增加 ruoyi-common-websocket 模块 支持token鉴权 支持分布式集群消息同步
This commit is contained in:
@ -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>-->
|
||||
|
@ -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("操作成功");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user