Skip to content

Commit

Permalink
autoconfig: Endpoint => consume / produce
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Mar 3, 2024
1 parent c0b76c2 commit a4d3a93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/autoconfig/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Endpoint } from "@ndn/endpoint";
import { consume, type ConsumerOptions } from "@ndn/endpoint";
import { type Forwarder, type FwFace, TapFace } from "@ndn/fw";
import { Interest, Name, type NameLike } from "@ndn/packet";
import type { H3Transport } from "@ndn/quic-transport";
Expand Down Expand Up @@ -121,15 +121,15 @@ async function testConnection(
const tapFace = TapFace.create(face);
tapFace.addRoute("/");
const abort = new AbortController();
const cOpts: ConsumerOptions = { fw: tapFace.fw, signal: abort.signal };
try {
const endpoint = new Endpoint({ fw: tapFace.fw, signal: abort.signal });
await Promise.any(tc.map((pkt) => {
if (typeof pkt === "string" && pkt.endsWith("/*")) {
pkt = new Name(pkt.slice(0, -2)).append(Math.trunc(Math.random() * 1e8).toString().padStart(8, "0"));
}
const interest = pkt instanceof Interest ? pkt :
new Interest(pkt, Interest.CanBePrefix, Interest.Lifetime(testConnectionTimeout));
return endpoint.consume(interest);
return consume(interest, cOpts);
}));
} finally {
abort.abort();
Expand Down
6 changes: 3 additions & 3 deletions pkg/autoconfig/tests/network.t.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Endpoint } from "@ndn/endpoint";
import { produce } from "@ndn/endpoint";
import { Forwarder, type FwFace } from "@ndn/fw";
import { UdpServer, UdpServerForwarder } from "@ndn/node-transport/test-fixture/udp-server";
import { Data, Name } from "@ndn/packet";
Expand All @@ -17,10 +17,10 @@ afterEach(() => {

async function addServerWithDelayProducer(delayDuration: number): Promise<string> {
const server = await UdpServer.create(UdpServerForwarder);
const producer = new Endpoint({ fw: server.fw }).produce("/localhop/test-connection", async (interest) => {
const producer = produce("/localhop/test-connection", async (interest) => {
await delay(delayDuration);
return new Data(interest.name);
});
}, { fw: server.fw });
closers.push(server, producer);
return server.hostport;
}
Expand Down

0 comments on commit a4d3a93

Please sign in to comment.