From 2864c4eccf9768d55d060ca0b61a231dc10b349a Mon Sep 17 00:00:00 2001 From: PaulPlay <80539587+therealPaulPlay@users.noreply.github.com> Date: Mon, 10 Feb 2025 00:29:37 +0100 Subject: [PATCH] fix: adjust order again --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index a67503a..6f6ddf3 100644 --- a/src/index.js +++ b/src/index.js @@ -215,14 +215,14 @@ export default class PlayPeer { } incomingConnection.on('open', () => { - if (this.#hostConnections.findIndex(c => c[0] === incomingConnection) == -1) this.#hostConnections.push([incomingConnection, Date.now()]); // Add new peer - this.#triggerEvent("status", "Incoming connection opened."); - this.#triggerEvent("incomingPeerConnected", incomingConnection.peer); - // Sync host's connections with all peers + if (this.#hostConnections.findIndex(c => c[0] === incomingConnection) == -1) this.#hostConnections.push([incomingConnection, Date.now()]); // Add new peer const peerList = Array.from(this.#hostConnections).map(c => c[0]?.peer); this.#broadcastMessage("peer_list", { peers: peerList }); + this.#triggerEvent("status", "Incoming connection opened."); + this.#triggerEvent("incomingPeerConnected", incomingConnection.peer); + // Send current storage state to new peer try { incomingConnection.send({ type: 'storage_sync', storage: this.#storage });