*Update dist

This commit is contained in:
Derrick Hammer 2023-04-08 21:02:16 -04:00
parent 9740402e82
commit 79bbf5c144
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 165 additions and 156 deletions

21
dist/index.js vendored
View File

@ -71,8 +71,12 @@ export class SwarmClient extends Client {
}
async _listen() {
if (!this._connectionListener) {
this._connectionListener = this.connectModule("listenConnections", { swarm: this.swarm }, async (socketId) => {
const socket = this._sockets.get(socketId) ?? (await createSocket(socketId, this));
this._connectionListener = this.connectModule(
"listenConnections",
{ swarm: this.swarm },
async (socketId) => {
const socket =
this._sockets.get(socketId) ?? (await createSocket(socketId, this));
socket.on("close", () => {
this._sockets.delete(socketId);
});
@ -80,7 +84,8 @@ export class SwarmClient extends Client {
this._sockets.set(socketId, socket);
}
this.emit("connection", socket);
});
}
);
}
await this._connectionListener[1];
this._connectionListener = undefined;
@ -132,9 +137,13 @@ export class Socket extends Client {
await this.swarm.emitAsync("setup", this);
}
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.trackEvent(event, update);
promise.then(() => {
this.off(event, listener);
@ -169,7 +178,7 @@ export class Socket extends Client {
this.eventUpdates[event].push(update);
}
}
export const MODULE = "_AVKgzVYC8Sb_qiTA6kw5BDzQ4Ch-8D4sldQJl8dXF9oTw";
export const MODULE = "_AVbH2uOdd4s4hypKB3QqaP1kxJO_Q5m6y4hsEro6dpVJQ";
export const createClient = factory(SwarmClient, MODULE);
const socketFactory = factory(Socket, MODULE);
const createSocket = async (...args) => {