Skip to content

Commit 9aa4fec

Browse files
authored
fix: unify to entity.id the scene_id by comms, remove unused kernel code (#6156)
1 parent 049d0e3 commit 9aa4fec

File tree

9 files changed

+15
-19
lines changed

9 files changed

+15
-19
lines changed

browser-interface/packages/shared/apis/host/CommunicationsController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function registerCommunicationsControllerServiceServerImplementation(port
4848
* The `receiveCommsMessage` relays messages in direction: scene -> comms
4949
*/
5050
const commsController: ICommunicationsController = {
51-
cid: ctx.sceneData.id,
51+
cid: ctx.sceneData.entity.id || ctx.sceneData.id,
5252
receiveCommsMessage(preData: Uint8Array, sender: PeerInformation) {
5353
const [msgType, data] = decodeMessage(preData)
5454
if (msgType === MsgType.String) {
@@ -85,13 +85,13 @@ export function registerCommunicationsControllerServiceServerImplementation(port
8585
return {
8686
async send(req, ctx) {
8787
const message = textEncoder.encode(req.message)
88-
sendParcelSceneCommsMessage(ctx.sceneData.id, encodeMessage(message, MsgType.String))
88+
sendParcelSceneCommsMessage(commsController.cid, encodeMessage(message, MsgType.String))
8989
return {}
9090
},
9191
async sendBinary(req, ctx) {
9292
// Send messages
9393
for (const data of req.data) {
94-
sendParcelSceneCommsMessage(ctx.sceneData.id, encodeMessage(data, MsgType.Uint8Array))
94+
sendParcelSceneCommsMessage(commsController.cid, encodeMessage(data, MsgType.Uint8Array))
9595
}
9696

9797
// Process received messages

browser-interface/packages/shared/comms/sceneSubscriptions.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,3 @@ export function subscribeParcelSceneToCommsMessages(controller: ICommunicationsC
1414
export function unsubscribeParcelSceneToCommsMessages(controller: ICommunicationsController) {
1515
scenesSubscribedToCommsEvents.delete(controller)
1616
}
17-
18-
/**
19-
* Retrieve the scene IDs that are subscribed to receive scene messages from comms
20-
*
21-
* @returns a list of CIDs, identifying the Scenes by their hash
22-
*/
23-
export function getParcelSceneSubscriptions(): string[] {
24-
const ids: string[] = []
25-
26-
scenesSubscribedToCommsEvents.forEach(($) => {
27-
ids.push($.cid)
28-
})
29-
30-
return ids
31-
}

browser-interface/packages/shared/scene-loader/genesis-city-loader-impl/emptyParcelController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class EmptyParcelController {
3636
id: entityId,
3737
baseUrl: this.baseUrl + 'contents/',
3838
entity: {
39+
id: entityId,
3940
content: emptyScenes[sceneName]!,
4041
pointers: [coordinates],
4142
timestamp: Date.now(),

browser-interface/packages/shared/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export type SceneSourcePlacement = {
181181
export const VOICE_CHAT_FEATURE_TOGGLE: SceneFeatureToggle = { name: 'voiceChat', default: 'enabled' }
182182

183183
export type LoadableScene = {
184-
readonly entity: Readonly<Omit<Entity, 'id'>>
184+
readonly entity: Readonly<Entity>
185185
readonly baseUrl: string
186186
readonly id: string
187187
/** Id of the parent scene that spawned this scene experience */

browser-interface/packages/shared/wearablesPortableExperience/sagas.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ export async function wearableToSceneEntity(wearable: WearableV2, defaultBaseUrl
154154
baseUrl,
155155
parentCid: 'avatar',
156156
entity: {
157+
// TODO: the wearable.id is an urn because the wearable was fetched
158+
// from `lambdas/wearables` instead of `content/entities/active`
159+
id: wearable.id,
157160
content,
158161
metadata,
159162
pointers: [wearable.id],

browser-interface/packages/unity-interface/dcl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async function startGlobalScene(cid: string, title: string, fileContentUrl: stri
110110
id: cid,
111111
baseUrl,
112112
entity: {
113+
id: cid,
113114
content: [...extraContent, { file: 'scene.js', hash: fileContentUrl }],
114115
pointers: [cid],
115116
timestamp: 0,

browser-interface/packages/unity-interface/portableExperiencesUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export async function getPortableExperienceFromUrn(sceneUrn: string): Promise<Lo
8585

8686
const result = await fetch(resolvedUrl)
8787
const entity = (await result.json()) as Entity
88+
if (!entity.id) {
89+
entity.id = resolvedEntity.cid
90+
}
91+
8892
const baseUrl: string = resolvedEntity.baseUrl || new URL('.', resolvedUrl).toString()
8993

9094
return {

browser-interface/test/unit/RestrictedActions.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ describe('RestrictedActions tests', () => {
187187
sceneNumber: 3,
188188
baseUrl: '',
189189
entity: {
190+
id: 'test',
190191
version: 'v3',
191192
content: [],
192193
pointers: [],

browser-interface/test/unit/portableExperiences.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('Portable experiences sagas test', () => {
2222
id: urn,
2323
baseUrl: '',
2424
entity: {
25+
id: urn,
2526
content: [],
2627
metadata: {
2728
menuBarIcon: 'icon'

0 commit comments

Comments
 (0)