*Update dist
This commit is contained in:
parent
9740402e82
commit
79bbf5c144
|
@ -71,8 +71,12 @@ export class SwarmClient extends Client {
|
||||||
}
|
}
|
||||||
async _listen() {
|
async _listen() {
|
||||||
if (!this._connectionListener) {
|
if (!this._connectionListener) {
|
||||||
this._connectionListener = this.connectModule("listenConnections", { swarm: this.swarm }, async (socketId) => {
|
this._connectionListener = this.connectModule(
|
||||||
const socket = this._sockets.get(socketId) ?? (await createSocket(socketId, this));
|
"listenConnections",
|
||||||
|
{ swarm: this.swarm },
|
||||||
|
async (socketId) => {
|
||||||
|
const socket =
|
||||||
|
this._sockets.get(socketId) ?? (await createSocket(socketId, this));
|
||||||
socket.on("close", () => {
|
socket.on("close", () => {
|
||||||
this._sockets.delete(socketId);
|
this._sockets.delete(socketId);
|
||||||
});
|
});
|
||||||
|
@ -80,7 +84,8 @@ export class SwarmClient extends Client {
|
||||||
this._sockets.set(socketId, socket);
|
this._sockets.set(socketId, socket);
|
||||||
}
|
}
|
||||||
this.emit("connection", socket);
|
this.emit("connection", socket);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this._connectionListener[1];
|
await this._connectionListener[1];
|
||||||
this._connectionListener = undefined;
|
this._connectionListener = undefined;
|
||||||
|
@ -132,9 +137,13 @@ export class Socket extends Client {
|
||||||
await this.swarm.emitAsync("setup", this);
|
await this.swarm.emitAsync("setup", this);
|
||||||
}
|
}
|
||||||
on(event, listener, options) {
|
on(event, listener, options) {
|
||||||
const [update, promise] = this.connectModule("socketListenEvent", { id: this.id, event: event }, (data) => {
|
const [update, promise] = this.connectModule(
|
||||||
|
"socketListenEvent",
|
||||||
|
{ id: this.id, event: event },
|
||||||
|
(data) => {
|
||||||
this.emit(event, data);
|
this.emit(event, data);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
this.trackEvent(event, update);
|
this.trackEvent(event, update);
|
||||||
promise.then(() => {
|
promise.then(() => {
|
||||||
this.off(event, listener);
|
this.off(event, listener);
|
||||||
|
@ -169,7 +178,7 @@ export class Socket extends Client {
|
||||||
this.eventUpdates[event].push(update);
|
this.eventUpdates[event].push(update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const MODULE = "_AVKgzVYC8Sb_qiTA6kw5BDzQ4Ch-8D4sldQJl8dXF9oTw";
|
export const MODULE = "_AVbH2uOdd4s4hypKB3QqaP1kxJO_Q5m6y4hsEro6dpVJQ";
|
||||||
export const createClient = factory(SwarmClient, MODULE);
|
export const createClient = factory(SwarmClient, MODULE);
|
||||||
const socketFactory = factory(Socket, MODULE);
|
const socketFactory = factory(Socket, MODULE);
|
||||||
const createSocket = async (...args) => {
|
const createSocket = async (...args) => {
|
||||||
|
|
Loading…
Reference in New Issue