Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unify to entity.id the scene_id by comms, remove unused code #6156

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function registerCommunicationsControllerServiceServerImplementation(port
* The `receiveCommsMessage` relays messages in direction: scene -> comms
*/
const commsController: ICommunicationsController = {
cid: ctx.sceneData.id,
cid: ctx.sceneData.entity.id || ctx.sceneData.id,
receiveCommsMessage(preData: Uint8Array, sender: PeerInformation) {
const [msgType, data] = decodeMessage(preData)
if (msgType === MsgType.String) {
Expand Down Expand Up @@ -85,13 +85,13 @@ export function registerCommunicationsControllerServiceServerImplementation(port
return {
async send(req, ctx) {
const message = textEncoder.encode(req.message)
sendParcelSceneCommsMessage(ctx.sceneData.id, encodeMessage(message, MsgType.String))
sendParcelSceneCommsMessage(commsController.cid, encodeMessage(message, MsgType.String))
return {}
},
async sendBinary(req, ctx) {
// Send messages
for (const data of req.data) {
sendParcelSceneCommsMessage(ctx.sceneData.id, encodeMessage(data, MsgType.Uint8Array))
sendParcelSceneCommsMessage(commsController.cid, encodeMessage(data, MsgType.Uint8Array))
}

// Process received messages
Expand Down
15 changes: 0 additions & 15 deletions browser-interface/packages/shared/comms/sceneSubscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,3 @@ export function subscribeParcelSceneToCommsMessages(controller: ICommunicationsC
export function unsubscribeParcelSceneToCommsMessages(controller: ICommunicationsController) {
scenesSubscribedToCommsEvents.delete(controller)
}

/**
* Retrieve the scene IDs that are subscribed to receive scene messages from comms
*
* @returns a list of CIDs, identifying the Scenes by their hash
*/
export function getParcelSceneSubscriptions(): string[] {
const ids: string[] = []

scenesSubscribedToCommsEvents.forEach(($) => {
ids.push($.cid)
})

return ids
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class EmptyParcelController {
id: entityId,
baseUrl: this.baseUrl + 'contents/',
entity: {
id: entityId,
content: emptyScenes[sceneName]!,
pointers: [coordinates],
timestamp: Date.now(),
Expand Down
2 changes: 1 addition & 1 deletion browser-interface/packages/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export type SceneSourcePlacement = {
export const VOICE_CHAT_FEATURE_TOGGLE: SceneFeatureToggle = { name: 'voiceChat', default: 'enabled' }

export type LoadableScene = {
readonly entity: Readonly<Omit<Entity, 'id'>>
readonly entity: Readonly<Entity>
readonly baseUrl: string
readonly id: string
/** Id of the parent scene that spawned this scene experience */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export async function wearableToSceneEntity(wearable: WearableV2, defaultBaseUrl
baseUrl,
parentCid: 'avatar',
entity: {
// TODO: the wearable.id is an urn because the wearable was fetched
// from `lambdas/wearables` instead of `content/entities/active`
id: wearable.id,
content,
metadata,
pointers: [wearable.id],
Expand Down
1 change: 1 addition & 0 deletions browser-interface/packages/unity-interface/dcl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ async function startGlobalScene(cid: string, title: string, fileContentUrl: stri
id: cid,
baseUrl,
entity: {
id: cid,
content: [...extraContent, { file: 'scene.js', hash: fileContentUrl }],
pointers: [cid],
timestamp: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export async function getPortableExperienceFromUrn(sceneUrn: string): Promise<Lo

const result = await fetch(resolvedUrl)
const entity = (await result.json()) as Entity
if (!entity.id) {
entity.id = resolvedEntity.cid
}

const baseUrl: string = resolvedEntity.baseUrl || new URL('.', resolvedUrl).toString()

return {
Expand Down
1 change: 1 addition & 0 deletions browser-interface/test/unit/RestrictedActions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ describe('RestrictedActions tests', () => {
sceneNumber: 3,
baseUrl: '',
entity: {
id: 'test',
version: 'v3',
content: [],
pointers: [],
Expand Down
1 change: 1 addition & 0 deletions browser-interface/test/unit/portableExperiences.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Portable experiences sagas test', () => {
id: urn,
baseUrl: '',
entity: {
id: urn,
content: [],
metadata: {
menuBarIcon: 'icon'
Expand Down
Loading