package com.ruoyi.imserver.netty.processor;


import com.ruoyi.common.im.enums.IMCmdType;
import com.ruoyi.imserver.util.SpringContextHolder;

public class ProcessorFactory {

    public static AbstractMessageProcessor createProcessor(IMCmdType cmd) {

          switch (cmd) {
            case LOGIN:
                return SpringContextHolder.getApplicationContext().getBean(LoginProcessor.class);
            case HEART_BEAT:
                return SpringContextHolder.getApplicationContext().getBean(HeartbeatProcessor.class);
            case PRIVATE_MESSAGE:
                return SpringContextHolder.getApplicationContext().getBean(PrivateMessageProcessor.class);
            case GROUP_MESSAGE:
                return SpringContextHolder.getApplicationContext().getBean(GroupMessageProcessor.class);
            case SYSTEM_MESSAGE:
                return SpringContextHolder.getApplicationContext().getBean(SystemMessageProcessor.class);
            default:
                return null;
        }
    }

}
