package com.ruoyi.other.controller;
|
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.other.webSocket.NettyChannelMap;
|
import com.ruoyi.other.webSocket.NettyWebSocketController;
|
import io.netty.channel.ChannelHandlerContext;
|
import org.springframework.web.bind.annotation.*;
|
|
/**
|
* @author zhibing.pu
|
* @Date 2024/8/21 17:31
|
*/
|
@RestController
|
@RequestMapping("/webSocket")
|
public class WebSocketController {
|
|
|
/**
|
* 发送websocket消息
|
* @param userId
|
* @param msg
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/send")
|
public R send(@RequestParam("userId") Long userId, @RequestParam("msg") String msg){
|
ChannelHandlerContext channel = NettyChannelMap.getData("Applets" + userId);
|
return NettyWebSocketController.sendMsgToClient(channel, msg);
|
}
|
|
}
|