| | |
| | | */ |
| | | @Slf4j |
| | | @Component("msgDispatch") |
| | | public class MsgDispatch implements ApplicationContextAware { |
| | | |
| | | private ApplicationContext applicationContext; |
| | | public class MsgDispatch { |
| | | |
| | | @Autowired |
| | | private MsgLogic msgLogic; |
| | | |
| | | public void webSocketDispatch(ChannelHandlerContext ctx, String msg) { |
| | | log.info("==========={}", msg); |
| | | RequestBean requestBean = null; |
| | | try { |
| | | requestBean = JSONObject.parseObject(msg, RequestBean.class); |
| | | requestBean.setChannelId(ctx.channel().id().asShortText()); |
| | | msgLogic.webSocketMsgLogic(requestBean); |
| | | } catch (Exception e) { |
| | | log.info("#websocket json error:{}#", e); |
| | | ctx.channel().writeAndFlush(NettyTools.webSocketBytes("params error")); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
| | | this.applicationContext = applicationContext; |
| | | } |
| | | } |