Compare commits

..

No commits in common. "f7a5628a9110bdd0d05958480e950bcf72af568a" and "79bbf5c144fb8b14ee43cc3d3cd96bd46f8aefa1" have entirely different histories.

3 changed files with 167 additions and 158 deletions

2
dist/index.d.ts vendored
View File

@ -47,6 +47,6 @@ export declare class Socket extends Client {
private ensureEvent;
private trackEvent;
}
export declare const MODULE = "_AV0jHIhooJYvu8a9_9os4aTHQP-QlDymCtvbFCuPcpetw";
export declare const MODULE = "_AVKgzVYC8Sb_qiTA6kw5BDzQ4Ch-8D4sldQJl8dXF9oTw";
export declare const createClient: (...args: any) => SwarmClient;
//# sourceMappingURL=index.d.ts.map

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 = "_AV0jHIhooJYvu8a9_9os4aTHQP-QlDymCtvbFCuPcpetw";
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 = "_AV0jHIhooJYvu8a9_9os4aTHQP-QlDymCtvbFCuPcpetw";
export const MODULE = "_AVbH2uOdd4s4hypKB3QqaP1kxJO_Q5m6y4hsEro6dpVJQ";
export const createClient = factory<SwarmClient>(SwarmClient, MODULE);