From f11e3fed7826bc60b068dcd11d8997b948aec8bd Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 15 Apr 2023 22:37:49 -0400 Subject: [PATCH] *implement handlePeer --- src/proxies/multiSocket.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/proxies/multiSocket.ts b/src/proxies/multiSocket.ts index fc1e017..77e3527 100644 --- a/src/proxies/multiSocket.ts +++ b/src/proxies/multiSocket.ts @@ -4,7 +4,7 @@ import { json, raw, uint } from "compact-encoding"; import { deserializeError } from "serialize-error"; import b4a from "b4a"; import type { TcpSocketConnectOpts } from "net"; -import Peer, { DataSocketOptions, PeerOptions } from "../peer.js"; +import { DataSocketOptions, PeerOptions } from "../peer.js"; import { roundRobinFactory, idFactory } from "../util.js"; import { CloseSocketRequest, @@ -14,6 +14,7 @@ import { WriteSocketRequest, } from "./multiSocket/types.js"; import DummySocket from "./multiSocket/dummySocket.js"; +import Peer from "./multiSocket/peer.js"; export interface MultiSocketProxyOptions extends ProxyOptions { socketClass?: any; @@ -69,7 +70,15 @@ const errorSocketEncoding = { const nextSocketId = idFactory(1); export default class MultiSocketProxy extends Proxy { - handlePeer({ peer, muxer, ...options }: DataSocketOptions & PeerOptions) {} + handlePeer({ peer, muxer, ...options }: DataSocketOptions & PeerOptions) { + new Peer({ + ...this.socketOptions, + proxy: this, + peer, + muxer, + ...options, + }); + } private socketClass: any; private _peers: Map = new Map(); private _nextPeer = roundRobinFactory(this._peers);