Skip to content

Commit

Permalink
fix: adjust order again
Browse files Browse the repository at this point in the history
  • Loading branch information
therealPaulPlay committed Feb 9, 2025
1 parent 0b76334 commit 2864c4e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit 2864c4e

Please sign in to comment.