package com.xcong.farmer.cms.netty.dispatch;
|
|
import com.xcong.farmer.cms.netty.bean.RequestBean;
|
import com.xcong.farmer.cms.netty.common.NettyTools;
|
import com.xcong.farmer.cms.netty.logic.MsgLogic;
|
import io.netty.channel.ChannelHandlerContext;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.BeansException;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.stereotype.Component;
|
|
|
/**
|
* @author wzy
|
* @date 2019-05-08
|
*/
|
@Slf4j
|
@Component("msgDispatch")
|
public class MsgDispatch implements ApplicationContextAware {
|
|
private ApplicationContext applicationContext;
|
|
@Autowired
|
private MsgLogic msgLogic;
|
|
public void webSocketDispatch(ChannelHandlerContext ctx, String msg) {
|
log.info("==========={}", msg);
|
RequestBean requestBean = null;
|
try {
|
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;
|
}
|
}
|