diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-04-26 13:15:09 -0300 |
---|---|---|
committer | (quasar) nebula <towerofnix@gmail.com> | 2021-04-26 13:15:09 -0300 |
commit | 84c49e453336d6105655edd08e93bab071c0fc3b (patch) | |
tree | 4b65a3dd7d08c1652408b293c659fcef37347241 /backend.js | |
parent | a1aa060f848e7d8da29142954c4f642970fc3fab (diff) |
synchronize shared sources on join + other stuff
Diffstat (limited to 'backend.js')
-rw-r--r-- | backend.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/backend.js b/backend.js index 3d9c386..0f15a43 100644 --- a/backend.js +++ b/backend.js @@ -672,6 +672,11 @@ class Backend extends EventEmitter { this.waitWhenDonePlaying = false this.hasAnnouncedJoin = false + this.sharedSourcesMap = Object.create(null) + this.sharedSourcesGrouplike = { + name: 'Shared Sources', + items: [] + } this.recordStore = new RecordStore() this.throttleMetadata = throttlePromise(10) @@ -873,17 +878,26 @@ class Backend extends EventEmitter { this.hasAnnouncedJoin = hasAnnouncedJoin } - loadPartyGrouplike(socketId, partyGrouplike) { - this.emit('got party grouplike', socketId, partyGrouplike) + loadSharedSources(socketId, sharedSources) { + if (socketId in this.sharedSourcesMap) { + return + } + + this.sharedSourcesMap[socketId] = sharedSources + + sharedSources[parentSymbol] = this.sharedSourcesGrouplike + this.sharedSourcesGrouplike.items.push(sharedSources) + + this.emit('got shared sources', socketId, sharedSources) + } + + sharedSourcesUpdated(socketId, sharedSources) { + this.emit('shared sources updated', socketId, sharedSources) } shareWithParty(item) { this.emit('share with party', item) } - - partyGrouplikeUpdated(socketId, partyGrouplike) { - this.emit('party grouplike updated', socketId, partyGrouplike) - } } module.exports = Backend |