From 40e139df0dc99b2705597830f3e129748a24f238 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 16 Apr 2023 03:06:53 -0400 Subject: [PATCH] *Update dist --- dist/proxies/multiSocket.d.ts | 2 +- dist/proxies/multiSocket.js | 34 +++++++++++++++--------------- dist/proxies/multiSocket/peer.d.ts | 1 + dist/proxies/multiSocket/peer.js | 5 ++++- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/dist/proxies/multiSocket.d.ts b/dist/proxies/multiSocket.d.ts index ea254d5..7f0c579 100644 --- a/dist/proxies/multiSocket.d.ts +++ b/dist/proxies/multiSocket.d.ts @@ -21,7 +21,7 @@ export default class MultiSocketProxy extends Proxy { get socketMap(): Map; private _sockets; get sockets(): Map; - handleNewPeerChannel(peer: Peer, channel: any): void; + handleNewPeerChannel(peer: Peer): void; handleClosePeer(peer: Peer): Promise; get(pubkey: Uint8Array): PeerEntity | undefined; update(pubkey: Uint8Array, data: Partial): void; diff --git a/dist/proxies/multiSocket.js b/dist/proxies/multiSocket.js index c43bf28..f32b310 100644 --- a/dist/proxies/multiSocket.js +++ b/dist/proxies/multiSocket.js @@ -94,13 +94,13 @@ class MultiSocketProxy extends proxy_js_1.default { get sockets() { return this._sockets; } - handleNewPeerChannel(peer, channel) { - this.update(peer.socket.remotePublicKey, { peer }); - this._registerOpenSocketMessage(peer, channel); - this._registerWriteSocketMessage(peer, channel); - this._registerCloseSocketMessage(peer, channel); - this._registerTimeoutSocketMessage(peer, channel); - this._registerErrorSocketMessage(peer, channel); + handleNewPeerChannel(peer) { + this.update(peer.stream.remotePublicKey, { peer }); + this._registerOpenSocketMessage(peer); + this._registerWriteSocketMessage(peer); + this._registerCloseSocketMessage(peer); + this._registerTimeoutSocketMessage(peer); + this._registerErrorSocketMessage(peer); } async handleClosePeer(peer) { for (const item of this._sockets) { @@ -142,9 +142,9 @@ class MultiSocketProxy extends proxy_js_1.default { this._sockets.set(socketId, socket); return socket; } - _registerOpenSocketMessage(peer, channel) { + _registerOpenSocketMessage(peer) { const self = this; - const message = channel.addMessage({ + const message = peer.channel.addMessage({ encoding: { preencode: compact_encoding_1.json.preencode, encode: compact_encoding_1.json.encode, @@ -176,9 +176,9 @@ class MultiSocketProxy extends proxy_js_1.default { messages: { openSocket: message }, }); } - _registerWriteSocketMessage(peer, channel) { + _registerWriteSocketMessage(peer) { const self = this; - const message = channel.addMessage({ + const message = peer.channel.addMessage({ encoding: writeSocketEncoding, onmessage(m) { self._sockets.get(m.id)?.push(m.data); @@ -188,9 +188,9 @@ class MultiSocketProxy extends proxy_js_1.default { messages: { writeSocket: message }, }); } - _registerCloseSocketMessage(peer, channel) { + _registerCloseSocketMessage(peer) { const self = this; - const message = channel.addMessage({ + const message = peer.channel.addMessage({ encoding: socketEncoding, onmessage(m) { self._sockets.get(m.id)?.end(); @@ -200,9 +200,9 @@ class MultiSocketProxy extends proxy_js_1.default { messages: { closeSocket: message }, }); } - _registerTimeoutSocketMessage(peer, channel) { + _registerTimeoutSocketMessage(peer) { const self = this; - const message = channel.addMessage({ + const message = peer.channel.addMessage({ encoding: socketEncoding, onmessage(m) { // @ts-ignore @@ -213,9 +213,9 @@ class MultiSocketProxy extends proxy_js_1.default { messages: { timeoutSocket: message }, }); } - _registerErrorSocketMessage(peer, channel) { + _registerErrorSocketMessage(peer) { const self = this; - const message = channel.addMessage({ + const message = peer.channel.addMessage({ encoding: errorSocketEncoding, onmessage(m) { // @ts-ignore diff --git a/dist/proxies/multiSocket/peer.d.ts b/dist/proxies/multiSocket/peer.d.ts index 2e0c4cb..f17c221 100644 --- a/dist/proxies/multiSocket/peer.d.ts +++ b/dist/proxies/multiSocket/peer.d.ts @@ -4,6 +4,7 @@ import MultiSocketProxy from "../multiSocket.js"; export default class Peer extends BasePeer { protected _proxy: MultiSocketProxy; protected initSocket(): Promise; + get stream(): any; protected handleChannelOnClose(socket: Socket): Promise; protected handleChannelOnOpen(m: any): Promise; } diff --git a/dist/proxies/multiSocket/peer.js b/dist/proxies/multiSocket/peer.js index b0b3bbc..f763daa 100644 --- a/dist/proxies/multiSocket/peer.js +++ b/dist/proxies/multiSocket/peer.js @@ -6,11 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); const peer_js_1 = __importDefault(require("../../peer.js")); class Peer extends peer_js_1.default { async initSocket() { } + get stream() { + return this._muxer.stream; + } async handleChannelOnClose(socket) { return this._proxy.handleClosePeer(this); } async handleChannelOnOpen(m) { - await this._proxy.handleNewPeerChannel(this._peer, this._channel); + await this._proxy.handleNewPeerChannel(this); } } exports.default = Peer;