Skip to content

Commit

Permalink
fix: Incoming connection addition order
Browse files Browse the repository at this point in the history
  • Loading branch information
therealPaulPlay committed Feb 9, 2025
1 parent 03959de commit 0b76334
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playpeerjs",
"version": "1.2.7",
"version": "1.2.8",
"description": "WebRTC-based wrapper for creating robust peer-2-peer multiplayer systems with ease.",
"type": "module",
"main": "dist/playpeer.js",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ 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 });

Expand Down

0 comments on commit 0b76334

Please sign in to comment.