|
|
|
package com.crossoverjie.netty.action.controller;
|
|
|
|
|
|
|
|
import com.crossoverjie.netty.action.common.enums.StatusEnum;
|
|
|
|
import com.crossoverjie.netty.action.common.pojo.CustomProtocol;
|
|
|
|
import com.crossoverjie.netty.action.common.res.BaseResponse;
|
|
|
|
import com.crossoverjie.netty.action.common.util.RandomUtil;
|
|
|
|
import com.crossoverjie.netty.action.server.HeartBeatServer;
|
|
|
|
import com.crossoverjie.netty.action.vo.req.SendMsgReqVO;
|
|
|
|
import com.crossoverjie.netty.action.vo.res.SendMsgResVO;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function:
|
|
|
|
*
|
|
|
|
* @author crossoverJie
|
|
|
|
* Date: 22/05/2018 14:46
|
|
|
|
* @since JDK 1.8
|
|
|
|
*/
|
|
|
|
@Controller
|
|
|
|
@RequestMapping("/")
|
|
|
|
public class IndexController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private HeartBeatServer heartbeatClient ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 向服务端发消息
|
|
|
|
* @param sendMsgReqVO
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@ApiOperation("发送消息")
|
|
|
|
@RequestMapping("sendMsg")
|
|
|
|
@ResponseBody
|
|
|
|
public BaseResponse<SendMsgResVO> sendMsg(@RequestBody SendMsgReqVO sendMsgReqVO){
|
|
|
|
BaseResponse<SendMsgResVO> res = new BaseResponse();
|
|
|
|
heartbeatClient.sendMsg(new CustomProtocol(RandomUtil.getRandom(),sendMsgReqVO.getMsg())) ;
|
|
|
|
|
|
|
|
SendMsgResVO sendMsgResVO = new SendMsgResVO() ;
|
|
|
|
sendMsgResVO.setMsg("OK") ;
|
|
|
|
res.setCode(StatusEnum.SUCCESS.getCode()) ;
|
|
|
|
res.setMessage(StatusEnum.SUCCESS.getMessage()) ;
|
|
|
|
res.setDataBody(sendMsgResVO) ;
|
|
|
|
return res ;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|