From 4c927c7877c174e887d3f04429c5ab902aede8e2 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Wed, 20 Jan 2021 20:21:19 +1100 Subject: [PATCH 01/12] Added 1.7.0 social links --- src/docs/releaseNotes/v1.7.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/docs/releaseNotes/v1.7.0.md b/src/docs/releaseNotes/v1.7.0.md index bd9ef33..6b89316 100644 --- a/src/docs/releaseNotes/v1.7.0.md +++ b/src/docs/releaseNotes/v1.7.0.md @@ -56,6 +56,10 @@ In this update the fog tool has been changed to hopefully help work better with - Fixed a bug causing the colour of the glass and gemstone dice to be wrong. - Fixed a bug that would cause custom tokens to not load until a refresh. +[Reddit](https://www.reddit.com/r/OwlbearRodeo/comments/l15n7n/beta_v170_release_notes_fog_enhancements/) +[Twitter](https://twitter.com/OwlbearRodeo/status/1351819654113554434) +[Patreon](https://www.patreon.com/posts/v1-7-0-released-46437122) + --- Jan 20 2021 From cf63034c0e4915833d84f8c20e3ac757dbad60ce Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 07:12:44 +1100 Subject: [PATCH 02/12] Fix drawing null action --- src/helpers/drawing.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/helpers/drawing.js b/src/helpers/drawing.js index 69853b2..4731f4e 100644 --- a/src/helpers/drawing.js +++ b/src/helpers/drawing.js @@ -208,6 +208,9 @@ export function drawActionsToShapes(actions, actionIndex) { let shapesById = {}; for (let i = 0; i <= actionIndex; i++) { const action = actions[i]; + if (!action) { + continue; + } if (action.type === "add" || action.type === "edit") { for (let shape of action.shapes) { shapesById[shape.id] = shape; From af3839c9ff20a177fdc0dcf9c27381b624c199c4 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 07:14:32 +1100 Subject: [PATCH 03/12] Added null check to token status --- src/components/token/TokenStatus.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/components/token/TokenStatus.js b/src/components/token/TokenStatus.js index fdea596..6496eae 100644 --- a/src/components/token/TokenStatus.js +++ b/src/components/token/TokenStatus.js @@ -6,19 +6,20 @@ import colors from "../../helpers/colors"; function TokenStatus({ tokenState, width, height }) { return ( - {tokenState.statuses.map((status, index) => ( - - ))} + {tokenState && + tokenState.statuses.map((status, index) => ( + + ))} ); } From de3c601bb389f84cbe959fbe67f74ce66f99bd21 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 07:23:07 +1100 Subject: [PATCH 04/12] Added null check to useNetworkState update --- src/helpers/useNetworkedState.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/useNetworkedState.js b/src/helpers/useNetworkedState.js index df3e7f7..6f93308 100644 --- a/src/helpers/useNetworkedState.js +++ b/src/helpers/useNetworkedState.js @@ -88,7 +88,7 @@ function useNetworkedState( function handleSocketUpdateEvent(update) { _setState((prevState) => { - if (prevState[partialUpdatesKey] === update.id) { + if (prevState && prevState[partialUpdatesKey] === update.id) { let newState = { ...prevState }; applyChanges(newState, update.changes); lastSyncedStateRef.current = newState; From e892661016af9a9a2de11b4786beadab9899ffb5 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 08:44:46 +1100 Subject: [PATCH 05/12] Added checks for peer availability and fixed peer error handling --- src/network/Session.js | 22 ++++++++++++++++++---- src/routes/Game.js | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/network/Session.js b/src/network/Session.js index e38ea6e..d8c941c 100644 --- a/src/network/Session.js +++ b/src/network/Session.js @@ -119,7 +119,9 @@ class Session extends EventEmitter { */ sendTo(sessionId, eventId, data, channel) { if (!(sessionId in this.peers)) { - this._addPeer(sessionId, true); + if (!this._addPeer(sessionId, true)) { + return; + } } if (!this.peers[sessionId].ready) { @@ -146,7 +148,9 @@ class Session extends EventEmitter { */ startStreamTo(sessionId, track, stream) { if (!(sessionId in this.peers)) { - this._addPeer(sessionId, true); + if (!this._addPeer(sessionId, true)) { + return; + } } if (!this.peers[sessionId].ready) { @@ -192,6 +196,12 @@ class Session extends EventEmitter { this.socket.emit("join_game", gameId, password); } + /** + * Add a new peer connection + * @param {string} id + * @param {boolean} initiator + * @returns {boolean} True if peer was added successfully + */ _addPeer(id, initiator) { try { const connection = new Connection({ @@ -322,13 +332,15 @@ class Session extends EventEmitter { peer.connection.on("error", handleError.bind(this)); this.peers[id] = peer; + + return true; } catch (error) { logError(error); this.emit("peerError", { error }); - this.emit("disconnected"); for (let peer of Object.values(this.peers)) { peer.connection && peer.connection.destroy(); } + return false; } } @@ -374,7 +386,9 @@ class Session extends EventEmitter { _handleSignal(data) { const { from, signal } = data; if (!(from in this.peers)) { - this._addPeer(from, false); + if (!this._addPeer(from, false)) { + return; + } } this.peers[from].connection.signal(signal); } diff --git a/src/routes/Game.js b/src/routes/Game.js index 702180e..5df6f5a 100644 --- a/src/routes/Game.js +++ b/src/routes/Game.js @@ -66,9 +66,9 @@ function Game() { setPeerError("Unable to connect to party."); } } - session.on("error", handlePeerError); + session.on("peerError", handlePeerError); return () => { - session.off("error", handlePeerError); + session.off("peerError", handlePeerError); }; }, [session]); From ddf3a6daedbaa2d3bc344085e89cac428d9e21cf Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 11:29:39 +1100 Subject: [PATCH 06/12] Fix bug with adding tokens when no map is selected --- src/network/NetworkedMapAndTokens.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/NetworkedMapAndTokens.js b/src/network/NetworkedMapAndTokens.js index 8d39b50..e056dc8 100644 --- a/src/network/NetworkedMapAndTokens.js +++ b/src/network/NetworkedMapAndTokens.js @@ -273,6 +273,9 @@ function NetworkedMapAndTokens({ session }) { */ async function handleMapTokenStateCreate(tokenState) { + if (!currentMap || !currentMapState) { + return; + } // If file type token send the token to the other peers const token = getToken(tokenState.tokenId); if (token && token.type === "file") { From 4f76652eff5868c17e56ad40e04fb8959fac340e Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 13:51:23 +1100 Subject: [PATCH 07/12] Added null checks to asset manifest --- src/network/NetworkedMapAndTokens.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/network/NetworkedMapAndTokens.js b/src/network/NetworkedMapAndTokens.js index e056dc8..a27ee9c 100644 --- a/src/network/NetworkedMapAndTokens.js +++ b/src/network/NetworkedMapAndTokens.js @@ -50,7 +50,7 @@ function NetworkedMapAndTokens({ session }) { "mapId" ); const [assetManifest, setAssetManifest] = useNetworkedState( - [], + null, session, "manifest", 100, @@ -94,15 +94,17 @@ function NetworkedMapAndTokens({ session }) { function addAssetIfNeeded(asset) { // Asset needs updating - const exists = assetManifest.some((oldAsset) => + const exists = assetManifest?.some((oldAsset) => compareAssets(oldAsset, asset) ); - const needsUpdate = assetManifest.some((oldAsset) => + const needsUpdate = assetManifest?.some((oldAsset) => assetNeedsUpdate(oldAsset, asset) ); if (!exists || needsUpdate) { setAssetManifest((prevAssets) => [ - ...prevAssets.filter((prevAsset) => !compareAssets(prevAsset, asset)), + ...(prevAssets || []).filter( + (prevAsset) => !compareAssets(prevAsset, asset) + ), asset, ]); } @@ -286,7 +288,7 @@ function NetworkedMapAndTokens({ session }) { } function handleMapTokenStateChange(change) { - if (currentMapState === null) { + if (!currentMapState) { return; } setCurrentMapState((prevMapState) => ({ From 82e8eb014e65e658accec2270dded32f6d398fe2 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 13:58:37 +1100 Subject: [PATCH 08/12] Update TokenStatus.js --- src/components/token/TokenStatus.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/components/token/TokenStatus.js b/src/components/token/TokenStatus.js index 6496eae..fdea596 100644 --- a/src/components/token/TokenStatus.js +++ b/src/components/token/TokenStatus.js @@ -6,20 +6,19 @@ import colors from "../../helpers/colors"; function TokenStatus({ tokenState, width, height }) { return ( - {tokenState && - tokenState.statuses.map((status, index) => ( - - ))} + {tokenState.statuses.map((status, index) => ( + + ))} ); } From fcb10662c675f729f67ba1372dd6a134be024742 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 14:18:33 +1100 Subject: [PATCH 09/12] Added connection faq docs and ignore for WebRTC support error --- src/docs/faq/connection.md | 7 +++++++ src/index.js | 1 + src/routes/FAQ.js | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 src/docs/faq/connection.md diff --git a/src/docs/faq/connection.md b/src/docs/faq/connection.md new file mode 100644 index 0000000..7fa5d0b --- /dev/null +++ b/src/docs/faq/connection.md @@ -0,0 +1,7 @@ +## Connection + +--- + +### WebRTC not supported. + +If you see a WebRTC not supported message ensure you are using a browser that supports [WebRTC](https://caniuse.com/rtcpeerconnection) and also ensure that you don't have an extension that is blocking WebRTC connections. Some VPN extensions can cause this. diff --git a/src/index.js b/src/index.js index a503ace..8a7a4ad 100644 --- a/src/index.js +++ b/src/index.js @@ -25,6 +25,7 @@ if (process.env.REACT_APP_LOGGING === "true") { "QuotaExceededError", "XDR encoding failure", "Assertion failed: Input argument is not an HTMLInputElement", + "ERR_WEBRTC_SUPPORT", ], }); } diff --git a/src/routes/FAQ.js b/src/routes/FAQ.js index 6d1ebb1..29c90e7 100644 --- a/src/routes/FAQ.js +++ b/src/routes/FAQ.js @@ -11,6 +11,7 @@ const database = raw("../docs/faq/database.md"); const maps = raw("../docs/faq/maps.md"); const audioSharing = raw("../docs/faq/audio-sharing.md"); const general = raw("../docs/faq/general.md"); +const connection = raw("../docs/faq/connection.md"); function FAQ() { return ( @@ -45,6 +46,9 @@ function FAQ() { + + +