From 10a7b4ebc63f60fd622dd4621cc46b17276cadb2 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 16 Apr 2023 03:42:14 -0400 Subject: [PATCH] *Update dist --- dist/proxies/multiSocket.d.ts | 2 +- dist/proxies/multiSocket.js | 8 +++++--- dist/proxy.d.ts | 4 +++- dist/proxy.js | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dist/proxies/multiSocket.d.ts b/dist/proxies/multiSocket.d.ts index 7f0c579..5addfe8 100644 --- a/dist/proxies/multiSocket.d.ts +++ b/dist/proxies/multiSocket.d.ts @@ -10,7 +10,7 @@ export interface MultiSocketProxyOptions extends ProxyOptions { allowedPorts?: number[]; } export default class MultiSocketProxy extends Proxy { - handlePeer({ peer, muxer, ...options }: DataSocketOptions & PeerOptions): void; + handlePeer({ peer, muxer, ...options }: DataSocketOptions & PeerOptions): Promise; private socketClass; private _peers; private _nextPeer; diff --git a/dist/proxies/multiSocket.js b/dist/proxies/multiSocket.js index 33cc6af..f1ed856 100644 --- a/dist/proxies/multiSocket.js +++ b/dist/proxies/multiSocket.js @@ -55,14 +55,16 @@ const errorSocketEncoding = { }; const nextSocketId = (0, util_js_1.idFactory)(1); class MultiSocketProxy extends proxy_js_1.default { - handlePeer({ peer, muxer, ...options }) { - new peer_js_1.default({ + async handlePeer({ peer, muxer, ...options }) { + const conn = new peer_js_1.default({ ...this.socketOptions, proxy: this, peer, muxer, ...options, - }).init(); + }); + await conn.init(); + this.emit("peer", conn); } socketClass; _peers = new Map(); diff --git a/dist/proxy.d.ts b/dist/proxy.d.ts index f91af9c..7802219 100644 --- a/dist/proxy.d.ts +++ b/dist/proxy.d.ts @@ -1,11 +1,13 @@ +/// import { DataSocketOptions, PeerOptions } from "./peer.js"; +import EventEmitter from "events"; export interface ProxyOptions extends DataSocketOptions { swarm: any; protocol: string; listen?: boolean; autostart?: boolean; } -export default abstract class Proxy { +export default abstract class Proxy extends EventEmitter { protected _listen: any; protected _autostart: boolean; constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, onchannel, listen, autostart, emulateWebsocket, }: ProxyOptions); diff --git a/dist/proxy.js b/dist/proxy.js index e7feaaa..2c0af4e 100644 --- a/dist/proxy.js +++ b/dist/proxy.js @@ -4,10 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const protomux_1 = __importDefault(require("protomux")); -class Proxy { +const events_1 = __importDefault(require("events")); +class Proxy extends events_1.default { _listen; _autostart; constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, onchannel, listen = false, autostart = false, emulateWebsocket = false, }) { + super(); this._swarm = swarm; this._protocol = protocol; this._listen = listen;