*update dist
This commit is contained in:
parent
f11e3fed78
commit
a8419313b5
|
@ -1,8 +1,9 @@
|
||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
import Proxy, { ProxyOptions } from "../proxy.js";
|
import Proxy, { ProxyOptions } from "../proxy.js";
|
||||||
import type { TcpSocketConnectOpts } from "net";
|
import type { TcpSocketConnectOpts } from "net";
|
||||||
import Peer, { DataSocketOptions, PeerOptions } from "../peer.js";
|
import { DataSocketOptions, PeerOptions } from "../peer.js";
|
||||||
import { PeerEntity } from "./multiSocket/types.js";
|
import { PeerEntity } from "./multiSocket/types.js";
|
||||||
|
import Peer from "./multiSocket/peer.js";
|
||||||
export interface MultiSocketProxyOptions extends ProxyOptions {
|
export interface MultiSocketProxyOptions extends ProxyOptions {
|
||||||
socketClass?: any;
|
socketClass?: any;
|
||||||
server: boolean;
|
server: boolean;
|
||||||
|
|
|
@ -10,6 +10,7 @@ const serialize_error_1 = require("serialize-error");
|
||||||
const b4a_1 = __importDefault(require("b4a"));
|
const b4a_1 = __importDefault(require("b4a"));
|
||||||
const util_js_1 = require("../util.js");
|
const util_js_1 = require("../util.js");
|
||||||
const dummySocket_js_1 = __importDefault(require("./multiSocket/dummySocket.js"));
|
const dummySocket_js_1 = __importDefault(require("./multiSocket/dummySocket.js"));
|
||||||
|
const peer_js_1 = __importDefault(require("./multiSocket/peer.js"));
|
||||||
const socketEncoding = {
|
const socketEncoding = {
|
||||||
preencode(state, m) {
|
preencode(state, m) {
|
||||||
compact_encoding_1.uint.preencode(state, m.id);
|
compact_encoding_1.uint.preencode(state, m.id);
|
||||||
|
@ -54,7 +55,15 @@ const errorSocketEncoding = {
|
||||||
};
|
};
|
||||||
const nextSocketId = (0, util_js_1.idFactory)(1);
|
const nextSocketId = (0, util_js_1.idFactory)(1);
|
||||||
class MultiSocketProxy extends proxy_js_1.default {
|
class MultiSocketProxy extends proxy_js_1.default {
|
||||||
handlePeer({ peer, muxer, ...options }) { }
|
handlePeer({ peer, muxer, ...options }) {
|
||||||
|
new peer_js_1.default({
|
||||||
|
...this.socketOptions,
|
||||||
|
proxy: this,
|
||||||
|
peer,
|
||||||
|
muxer,
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
}
|
||||||
socketClass;
|
socketClass;
|
||||||
_peers = new Map();
|
_peers = new Map();
|
||||||
_nextPeer = (0, util_js_1.roundRobinFactory)(this._peers);
|
_nextPeer = (0, util_js_1.roundRobinFactory)(this._peers);
|
||||||
|
@ -62,9 +71,6 @@ class MultiSocketProxy extends proxy_js_1.default {
|
||||||
_allowedPorts = [];
|
_allowedPorts = [];
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
this._socketOptions.onchannel = this.handleNewPeerChannel.bind(this);
|
|
||||||
this._socketOptions.onclose = this.handleClosePeer.bind(this);
|
|
||||||
this._socketOptions.onopen = this.handlePeer.bind(this);
|
|
||||||
if (options.socketClass) {
|
if (options.socketClass) {
|
||||||
this.socketClass = options.socketClass;
|
this.socketClass = options.socketClass;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue