| | |
| | | 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.ServerChannelManager; |
| | | import com.xcong.excoin.netty.common.NettyTools; |
| | | import io.netty.channel.Channel; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | |
| | | |
| | | public void webReqConnection(RequestBean requestBean) { |
| | | Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId()); |
| | | Channel channel = ServerChannelManager.findWebSocketChannel(requestBean.getChannelId()); |
| | | channel.writeAndFlush(NettyTools.webSocketBytes("this is ok")); |
| | | } |
| | | |
| | |
| | | String type = jsonObject.getString("type"); |
| | | ResponseBean responseBean = ResponseBean.ok(requestBean.getType(), null); |
| | | |
| | | Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId()); |
| | | Channel channel = ServerChannelManager.findWebSocketChannel(requestBean.getChannelId()); |
| | | channel.writeAndFlush(NettyTools.webSocketBytes(JSONObject.toJSONString(responseBean))); |
| | | } |
| | | |
| | | public void defaultReq(RequestBean requestBean) { |
| | | Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId()); |
| | | Channel channel = ServerChannelManager.findWebSocketChannel(requestBean.getChannelId()); |
| | | channel.writeAndFlush("this is error type"); |
| | | } |
| | | } |