From 84c49e453336d6105655edd08e93bab071c0fc3b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 26 Apr 2021 13:15:09 -0300 Subject: synchronize shared sources on join + other stuff --- backend.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'backend.js') 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 -- cgit 1.3.0-6-gf8a5