mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
fixed bug: LogicFace.receiveInterest&Data
This commit is contained in:
1 parent
18dbeb894e
commit
2a3288c076
5 files changed
+80
-18
No files matched your search
@@ -2,9 +2,12 @@ package logicface;
|
||||
|
||||
import component.*;
|
||||
import encoding.*;
|
||||
import mgmt.MgmtException;
|
||||
import packet.*;
|
||||
import util.ByteHelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.channels.DatagramChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
@@ -228,7 +229,7 @@ public class LogicFace {
|
||||
try {
|
||||
while (true){
|
||||
MINPacket minPacket=this.receivePacket(timeout);
|
||||
int packetType=minPacket.packetType.getVlIntValue2Int();
|
||||
int packetType=minPacket.getPacketType().getVlIntValue2Int();
|
||||
if(packetType == TLV.TlvIdentifierCommon){
|
||||
CPacket cPacket=new CPacket().createCPacketByMINPacket(minPacket);
|
||||
return cPacket;
|
||||
@@ -248,19 +249,14 @@ public class LogicFace {
|
||||
public Interest receiveInterest(long timeout) throws LogicFaceException {
|
||||
try {
|
||||
while (true){
|
||||
System.out.println("receiveInterest ing...");
|
||||
MINPacket minPacket=this.receivePacket(timeout);
|
||||
System.out.println("minpacket: "+new SelfEncodingBase().selfWireEncode(minPacket).getRaw());
|
||||
int packetType=minPacket.packetType.getVlIntValue2Int();
|
||||
int packetType=minPacket.getPacketType().getVlIntValue2Int();
|
||||
if(packetType == TLV.TlvIdentifierContentInterest){
|
||||
Interest interest=new Interest().createInterestByMINPacket(minPacket);
|
||||
return interest;
|
||||
}else{
|
||||
// System.out.println(new SelfEncodingBase().selfWireEncode(minPacket).getRaw());
|
||||
}
|
||||
System.out.println(new SelfEncodingBase().selfWireEncode(minPacket).getRaw());
|
||||
}
|
||||
} catch (VlIntException | PacketException | EncoderException | BlockException | ComponentException | MgmtException e) {
|
||||
} catch (VlIntException | PacketException e) {
|
||||
throw new LogicFaceException("LogicFace.receiveInterest: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -274,7 +270,7 @@ public class LogicFace {
|
||||
try {
|
||||
while (true){
|
||||
MINPacket minPacket=this.receivePacket(timeout);
|
||||
int packetType=minPacket.packetType.getVlIntValue2Int();
|
||||
int packetType=minPacket.getPacketType().getVlIntValue2Int();
|
||||
if(packetType == TLV.TlvIdentifierContentData){
|
||||
Data data=new Data().createDataByMINPacket(minPacket);
|
||||
return data;
|
||||
|
||||
@@ -168,7 +168,7 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
/////////////////////////////////////////////////////////////
|
||||
minPacket.identifierField.clearIdentifiers();
|
||||
IdentifierWrapper identifierWrapper =
|
||||
new IdentifierWrapper().createContentInterestIdentifierByComponents(this.name.getComponents());
|
||||
new IdentifierWrapper().createContentDataIdentifierByComponents(this.name.getComponents());
|
||||
if (identifierWrapper == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
//// 解析标识区
|
||||
/////////////////////////////////////////////////////////////
|
||||
IdentifierWrapper interestIdentifierWrapper =
|
||||
minPacket.identifierField.getIdentifierByType(new VlInt(TLV.TlvIdentifierContentInterest));
|
||||
minPacket.identifierField.getIdentifierByType(new VlInt(TLV.TlvIdentifierContentData));
|
||||
if (interestIdentifierWrapper == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,18 @@ public class MINPacket implements IEncodingAble,IMINPacket {
|
||||
return TLV.isValidPacketType(packetType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得MINPacket中,第一个标识的类型
|
||||
* @return encoding.VlInt MINPacket中,第一个标识的类型
|
||||
*/
|
||||
public VlInt getPacketType() throws PacketException {
|
||||
try {
|
||||
IdentifierWrapper identifierWrapper=this.identifierField.getIdentifier(0);
|
||||
return identifierWrapper.getTlvType();
|
||||
} catch (ComponentException e) {
|
||||
throw new PacketException("MINPacket.getPacketType: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Packet 线速编码为 TLV
|
||||
@@ -113,6 +125,9 @@ public class MINPacket implements IEncodingAble,IMINPacket {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 解析包类型
|
||||
this.packetType=block.getType();
|
||||
|
||||
// 标记,用来记录是否满足必要条件
|
||||
boolean existIdentifier = false;
|
||||
|
||||
|
||||
Reference in new issue
Block a user