ndn: Data methods follow packet format order

This commit is contained in:
Junxiao Shi 2019-03-22 11:40:39 -04:00
parent 23241a5037
commit 0d3e8bf9c1
2 changed files with 30 additions and 26 deletions

View File

@ -3,19 +3,20 @@ import { Name } from "./name";
import { Signature } from "./signature";
export class Data {
constructor(name?: Name);
constructor(name?: Name|string);
constructor(data: Data);
getCongestionMark(): number;
getContent(): Blob;
getFullName(): Name;
getIncomingFaceId(): number;
getMetaInfo(): MetaInfo;
getName(): Name;
getFullName(): Name;
getMetaInfo(): MetaInfo;
getContent(): Blob;
getSignature(): Signature;
getCongestionMark(): number;
getIncomingFaceId(): number;
setContent(content: Blob): Data;
setMetaInfo(meta: MetaInfo): Data;
setName(name: Name): Data;
setMetaInfo(meta: MetaInfo): Data;
setContent(content: Blob|Buffer): Data;
setSignature(sig: Signature): Data;
wireDecode(input: Blob|Buffer): void;
@ -33,13 +34,13 @@ export enum ContentType {
export class MetaInfo {
constructor(meta?: MetaInfo);
getFinalBlockId(): Name.Component;
getFreshnessPeriod(): number;
getOtherTypeCode(): number;
getType(): ContentType;
getOtherTypeCode(): number;
getFreshnessPeriod(): number;
getFinalBlockId(): Name.Component;
setFinalBlockId(comp: Name.Component): void;
setFreshnessPeriod(freshness: number): void;
setOtherTypeCode(otherTypeCode: number): void;
setType(type: ContentType): void;
setOtherTypeCode(otherTypeCode: number): void;
setFreshnessPeriod(freshness: number): void;
setFinalBlockId(comp: Name.Component): void;
}

View File

@ -3,30 +3,33 @@ import ndn = require("ndn-js");
let meta = new ndn.MetaInfo();
meta = new ndn.MetaInfo(meta);
const comp: ndn.Name.Component = meta.getFinalBlockId();
let n: number = meta.getFreshnessPeriod();
n = meta.getOtherTypeCode();
const ct: ndn.ContentType = meta.getType();
let n: number = meta.getOtherTypeCode();
n = meta.getFreshnessPeriod();
const comp: ndn.Name.Component = meta.getFinalBlockId();
meta.setFinalBlockId(comp);
meta.setFreshnessPeriod(5000);
meta.setOtherTypeCode(1000);
meta.setType(ndn.ContentType.OTHER_CODE);
meta.setOtherTypeCode(1000);
meta.setFreshnessPeriod(5000);
meta.setFinalBlockId(comp);
let data = new ndn.Data();
data = new ndn.Data(new ndn.Name("/A"));
data = new ndn.Data("/A");
data = new ndn.Data(data);
n = data.getCongestionMark();
let blob: ndn.Blob = data.getContent();
let name: ndn.Name = data.getName();
n = data.getIncomingFaceId();
name = data.getFullName();
meta = data.getMetaInfo();
name = data.getName();
let blob: ndn.Blob = data.getContent();
const sig: ndn.Signature = data.getSignature();
n = data.getCongestionMark();
n = data.getIncomingFaceId();
data = data.setContent(blob)
data = data.setName(name)
.setMetaInfo(meta)
.setName(name)
.setContent(blob)
.setContent(Buffer.alloc(4))
.setSignature(sig);
data.wireDecode(blob);