Commit eb5ca491 by xmh

1

1 parent ce3e7046
......@@ -14,13 +14,13 @@ import org.springframework.context.annotation.Configuration;
public class FtpConfiguration {
@Value("${ftp.host:127.0.0.1}")
private String host;//主机名
private String host;
@Value("${ftp.port:21}")
private int port;//端口
private int port;
@Value("${ftp.username:}")
private String username;//用户名
private String username;
@Value("${ftp.password:}")
private String password;//密码
private String password;
@Value("${ftp.tempPath:}")
private String tempPath;
......@@ -33,7 +33,6 @@ public class FtpConfiguration {
ftpPoolConfig.setUsername(username);
ftpPoolConfig.setPassword(password);
//ftpPoolConfig.setMaxWaitMillis(1000);
//ftpPoolConfig.setMaxIdle(2);
return ftpPoolConfig;
}
......@@ -48,8 +47,7 @@ public class FtpConfiguration {
@Bean("ftpClientPool")
@ConditionalOnBean(FTPClientFactory.class)
public FTPClientPool ftpClientPool(FTPClientFactory ftpClientFactory) {
FTPClientPool ftpClientPool = new FTPClientPool(ftpClientFactory);
return ftpClientPool;
return new FTPClientPool(ftpClientFactory);
}
@Bean("ftpClientHelper")
......
......@@ -13,7 +13,7 @@ import lombok.Setter;
@Getter
@Setter
public abstract class BaseModel {
protected Long empty;
protected Long deviceId;
protected Long length;
protected Long firstInt;
protected Long secondInt;
......@@ -27,12 +27,37 @@ public abstract class BaseModel {
*
* @return model
*/
abstract public BaseModel decode(ByteBuf byteBuf);
public void decode(ByteBuf byteBuf) {
this.deviceId = byteBuf.readUnsignedInt();
this.length = byteBuf.readUnsignedInt();
this.firstInt = byteBuf.readUnsignedInt();
this.secondInt = byteBuf.readUnsignedInt();
this.data = new byte[(int) (length - 16)];
byteBuf.readBytes(data);
decodeData();
}
;
/**
* 将 model 转换为 byteBuf
*
* @return byteBuf
*/
abstract public ByteBuf encode();
public void encode(ByteBuf byteBuf) {
encodeData();
byteBuf.writeInt((int) (deviceId & 0xff));
byteBuf.writeInt((int) (length & 0xff));
byteBuf.writeInt((int) (firstInt & 0xff));
byteBuf.writeInt((int) (secondInt & 0xff));
byteBuf.writeBytes(data);
}
;
abstract protected void encodeData();
abstract protected void decodeData();
}
package com.viontech.model;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.Setter;
import java.nio.charset.StandardCharsets;
/**
* .
*
......@@ -17,14 +18,14 @@ public class LoginData extends BaseModel {
private String username;
private String password;
@Override
public BaseModel decode(ByteBuf byteBuf) {
return null;
protected void decodeData() {
this.username = new String(data, 0, 32, StandardCharsets.UTF_8);
this.password = new String(data, 32, 32, StandardCharsets.UTF_8);
}
@Override
public ByteBuf encode() {
return null;
protected void encodeData() {
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!