Helius
2021-05-26 3985fbaef190b95d71ec458993fd58a527239045
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)));
    }
 
 
}