package net.northking.cctp.element.internal.protocol.socket;

import net.northking.cctp.element.core.exception.ComponentRuntimeException;
import net.northking.cctp.element.internal.protocol.socket.cups8583.CupsMessageHandler;
import net.northking.cctp.element.internal.protocol.socket.def01.Def01MessageHandler;

/**
 * DefProtocolFactory
 *
 * @author fengxiang.zhang
 * @date 2022/4/15
 * @since 1.0
 */
public class MessageHandlerFactory {

    public static MessageHandler getHandler(String name, String charsetName, String head) {
        switch (name) {
            case "def01": {
                return new Def01MessageHandler(head,charsetName);
            }
            case "cups8583": {
                return new CupsMessageHandler(head,charsetName);
            }
        }
        throw new ComponentRuntimeException("未知的协议名称：" + name);
    }
}
