Skip to content

Commit

Permalink
add missing src/receive-endpoint-self-connected-default.mjs from temp…
Browse files Browse the repository at this point in the history
…late
  • Loading branch information
arlac77 committed Dec 4, 2020
1 parent a563550 commit 9b231fc
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/receive-endpoint-self-connected-default.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { ReceiveEndpointDefault } from "./receive-endpoint-default.mjs";

/**
* Receiving endpoint wich can also send to itself
*/
export class ReceiveEndpointSelfConnectedDefault extends ReceiveEndpointDefault {
get isOut() {
return true;
}

*connections() {
yield this;
yield* super.connections();
}

addConnection(other, backpointer) {
if (other === this) {
return;
}
return super.addConnection(other, backpointer);
}

removeConnection(other, backpointer) {
if (other === this) {
return;
}
return super.removeConnection(other, backpointer);
}

isConnected(other) {
if (this === other) {
return true;
}
return super.isConnected(other);
}

async send(...args) {
const interceptors = this.interceptors;
let c = 0;

const next = async (...args) =>
c >= interceptors.length
? this.receive(...args)
: interceptors[c++].receive(this, next, ...args);

return next(...args);
}
}

0 comments on commit 9b231fc

Please sign in to comment.