Compare commits

..

2 Commits

Author SHA1 Message Date
Derrick Hammer 79bbf5c144
*Update dist 2023-04-08 21:02:16 -04:00
Derrick Hammer 9740402e82
*Update module hash 2023-04-08 21:02:10 -04:00
2 changed files with 166 additions and 157 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) => {

View File

@ -255,7 +255,7 @@ export class Socket extends Client {
}
}
export const MODULE = "_AVKgzVYC8Sb_qiTA6kw5BDzQ4Ch-8D4sldQJl8dXF9oTw";
export const MODULE = "_AVbH2uOdd4s4hypKB3QqaP1kxJO_Q5m6y4hsEro6dpVJQ";
export const createClient = factory<SwarmClient>(SwarmClient, MODULE);