Commit 93a6874e by tiger

req rsp

1 parent 26a08e7f
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base;
public interface TcpReq<D extends TcpData> {
public class TcpReq<D extends TcpData> extends TcpBase<D> {
public TcpReq(byte type) {
super(type);
}
public TcpReq() {
this(TcpMapper.CMD_BLANK.getType());
}
}
......@@ -7,8 +7,6 @@ import lombok.Setter;
@Setter
public class TcpRsp<D extends TcpData> extends TcpBase<D> {
protected int error;
public TcpRsp(byte type) {
super(type);
}
......
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.req;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpBase;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.LoginRsp;
import cn.hutool.core.codec.Base64;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpRsp;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class DefaultReqHandler implements TcpHandler<TcpBase<TcpData>, LoginRsp> {
/**
* 默认请求处理器
*
* @author kome
* @date 2023年11月3日 下午3:56:53
*/
public class DefaultReqHandler implements TcpHandler<TcpReq<TcpData>, TcpRsp<TcpData>> {
@Override
public LoginRsp handle(Channel channel, TcpBase<TcpData> req) {
LoginRsp trsp = new LoginRsp();
// trsp.setReqKey(req.getReqKey());
// LoginQrcodeTcpData tdata = new LoginQrcodeTcpData();
// trsp.setData(tdata);
//
// try {
// DllClient client = DllFacade.openNewWxwork(req.getData().getUserId(), 0, "TcpReq");
//
// if (client == null) {
// trsp.setError(TcpErrorEnum.ERROR_OPERATION_FAILED.getError());
// return trsp;
// }
//
// SelfInfoDllData userInfo = client.getUserInfo();
// if (userInfo == null || userInfo.getUserId() == null) {
// int i = 50;
// while (client.getQrcodeData() == null && i-- > 0) {
// try {
// Thread.sleep(100);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// LoginQrcodeDllData data = client.getQrcodeData();
// if (data == null || data.getBase64EncodePath() == null) {
// trsp.setError(TcpErrorEnum.ERROR_OPERATION_FAILED.getError());
// return trsp;
// }
// String imagePath = data.getBase64EncodePath();
// log.info("loginQrcodePath:{}", imagePath);
// byte[] bytes = FileUtil.readBytes(new File(imagePath));
// tdata.setBase64EncodeQrcode(Base64.encode(bytes));
// tdata.setLoginQrcodeKey(data.getLoginQrcodeKey());
// } else {
// BeanUtils.copyProperties(userInfo, tdata);
// }
// } catch (Exception e) {
// e.printStackTrace();
// //
// trsp.setError(TcpErrorEnum.ERROR_USERID_NOT_LOGIN.getError());
// }
return trsp;
}
public static void main(String[] args) throws Exception {
String s = "{RDpc08O7p8S/wrxcztK1xM7EtbVcV1hXb3JrXHg1NDFpOG1rRzAzcUFWakxcSW1hZ2VcNTg4MjNhYzItNmVhNi00ZDJjLWE0OWUtNDZjZWM2ZTMzNzZhLmpwZw==}";
System.out.println(Base64.decodeStr(s));
System.out.println(new String(Base64.decode(s.getBytes("GBK")), "GBK"));
public TcpRsp<TcpData> handle(Channel channel, TcpReq<TcpData> req) {
TcpRsp<TcpData> rsp = new TcpRsp<>();
return rsp;
}
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpBase;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.LoginReqData;
......@@ -9,7 +8,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.LoginReqData;
* @author kome.jiang
* @date 2022年9月28日 下午2:48:32
*/
public class LoginReq extends TcpBase<LoginReqData> implements TcpReq<LoginReqData> {
public class LoginReq extends TcpReq<LoginReqData> {
public LoginReq() {
super(TcpMapper.CMD_REQ_LOGIN.getType());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!