shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.walker.tcp.handler;
 
import com.walker.tcp.Message;
import com.walker.tcp.Request;
 
/**
 * 系统默认长连接处理对象。该对象被重构
 * @author 时克英
 * @date 2018-11-27
 *
 */
@Deprecated
public class MyLongHandler extends MyMessageHandler {
 
    public MyLongHandler(){
        this.setEmptyMsgDisconnect(true);
    }
 
    @Override
    protected Request<?> createRequest(Message msg) throws Exception {
        throw new UnsupportedOperationException("该类型消息暂未实现。");
//        if(this.getMapper() == null){
//            throw new IllegalArgumentException(MSG_REQUEST_ERROR);
//        }
//        MessageProtocolResolver resolver = (MessageProtocolResolver)ConvertorUtils.getProtocolResolver(msg, getProtocolResolverList());
//        if(resolver == null){
//            throw new IllegalArgumentException("protocolResolver not found, msg : " + msg);
//        }
//
//        // 去掉报文中的分隔符,因为netty打开了显示分隔符
//        String content = msg.getPayload().toString().substring(0, msg.length()-resolver.getDelimiter().length());
//
//        String protocol = resolver.getProtocolNum(content, content.length());
//        String clazz = this.getMapper().get(protocol);
//        if(StringUtils.isEmpty(clazz)){
//            throw new IllegalArgumentException("请求协议对应的request类不存在。protocol = " + protocol + ", msg = " + content);
//        }
//        try {
//            Class<?> clazzRequest = ClassUtils.forName(clazz, this.getClass().getClassLoader());
//            AbstractStringRequest request = (AbstractStringRequest)clazzRequest.newInstance();
//            request.fromSource(content);
////            request.setProtocolResolver(resolver);
//            request.setProtocolResolverId(resolver.getOrder());
//            return request;
//
//        } catch (ClassNotFoundException e) {
//            logger.error("根据映射创建request对象错误:" + e.getMessage(), e);
//            throw new Exception(e);
//        }
    }
 
}