package org.springblade.webSocket;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import org.springblade.common.enums.AppConstant;
import org.springblade.core.tool.api.R;
import org.springblade.webSocket.dto.Message;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author cy-computer
 */
@RestController
@AllArgsConstructor
@RequestMapping("webSocket")
public class WebSocketController {
	@Resource
	private WebSocketServer webSocketServer;

	@PostMapping("sendInfo")
	public R sendInfo(@RequestBody Message message){
		webSocketServer.sendInfo(message.getSid(), message.getContent());
		return R.success("发送成功");
	}
}
