package com.xcong.excoin.netty.logic;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.xcong.excoin.netty.bean.RequestBean;
|
import com.xcong.excoin.netty.bean.ResponseBean;
|
import com.xcong.excoin.netty.common.ChannelManager;
|
import com.xcong.excoin.netty.common.NettyTools;
|
import io.netty.channel.Channel;
|
import org.springframework.stereotype.Component;
|
|
|
/**
|
* @author wzy
|
* @email wangdoubleone@gmail.com
|
* @date 2019-05-09
|
*/
|
@Component
|
public class WebSocketLogic {
|
|
public void authCheck(RequestBean requestBean) {
|
Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId());
|
|
ChannelManager.addWsChannel(channel, Long.parseLong(requestBean.getData().toString()));
|
|
ResponseBean responseBean = new ResponseBean();
|
responseBean.setType(requestBean.getType());
|
responseBean.setStatus(1);
|
channel.writeAndFlush(NettyTools.webSocketBytes(JSONObject.toJSONString(responseBean)));
|
}
|
|
|
}
|