package com.iplatform.tcp.support;
|
|
import com.walker.tcp.littleD.Constants;
|
import com.walker.tcp.littleD.LittleDProtocolResolver;
|
|
/**
|
* 平台TCP通信协议解析器实现。
|
* <p>沿用小D智能终端协议规范,#为结束标志,前缀可修改(2位),协议编号4位</p>
|
* @author 时克英
|
* @date 2023-04-17
|
*/
|
public class PlatformSharpProtocolResolver extends LittleDProtocolResolver {
|
|
public PlatformSharpProtocolResolver(){
|
this.setDelimiter(Constants.DATA_END_FLAG);
|
this.setProtocolFeature(Constants.BODY_ID);
|
this.setName("平台通信解析器");
|
this.setOrder(1);
|
}
|
|
// @Override
|
// protected String onResolve(String data, int size) throws ProtocolException {
|
// if(size < 6){
|
// throw new ProtocolException(ERR_PROTOCOL_SIZE);
|
// }
|
//
|
// if(!source.startsWith(this.getProtocolFeature().toString())){
|
// throw new ProtocolException(ERR_PROTOCOL_FEATURE);
|
// }
|
// return source.substring(2, 6);
|
// }
|
// @Override
|
// protected Response<?> doCreateOneResponse() {
|
// // 返回心跳响应
|
// return new HeartBeatResponse();
|
// }
|
// @Override
|
// public String getAuthenticateInfo(Request<?> request) throws AuthenticateException {
|
// if(request instanceof LoginRequest){
|
// String clientId = request.getName();
|
// if(StringUtils.isEmpty(clientId)){
|
// throw new AuthenticateException("请求信息中不存在设备ID号,无法认证");
|
// }
|
//
|
// if(!isPermitNotRegisterConnect() && !this.isRegistered(clientId)){
|
// throw new AuthenticateException("设备未在列表中注册,无法认证。clientId = " + clientId);
|
// }
|
// return clientId;
|
//
|
// } else {
|
// throw new AuthenticateException("connection通道认证失败,请求不是登录");
|
// }
|
// }
|
|
}
|