Skip to content

Commit b02aaf6

Browse files
committed
wip
1 parent 0f93827 commit b02aaf6

File tree

6 files changed

+41
-22
lines changed

6 files changed

+41
-22
lines changed

browser-interface/packages/config/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ export const WSS_ENABLED = !!ensureSingleString(qs.get('ws'))
7272
export const FORCE_SEND_MESSAGE = location.search.includes('FORCE_SEND_MESSAGE')
7373
export const ALLOW_SWIFT_SHADER = location.search.includes('ALLOW_SWIFT_SHADER')
7474

75+
export const DISABLE_SCENE_ROOM = location.search.includes('DISABLE_SCENE_ROOM')
76+
export const DISABLE_ISLAND_SCENE_MESSAGES = location.search.includes('DISABLE_ISLAND_SCENE_MESSAGES')
77+
7578
const ASSET_BUNDLES_DOMAIN = ensureSingleString(qs.get('ASSET_BUNDLES_DOMAIN'))
7679
export const SOCIAL_SERVER_URL = ensureSingleString(qs.get('SOCIAL_SERVER_URL'))
7780

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export function sendPublicChatMessage(message: string) {
1515

1616
export function sendParcelSceneCommsMessage(sceneId: string, data: Uint8Array) {
1717
const commsContext = getCommsRoom(store.getState())
18-
1918
commsContext
2019
?.sendParcelSceneMessage({
2120
data,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type CommsEvents = CommsAdapterEvents & {
1616
}
1717

1818
export interface RoomConnection {
19+
id?: string
1920
// this operation is non-reversible
2021
disconnect(): Promise<void>
2122
// @once

browser-interface/packages/shared/comms/logic/rfc-4-room-connection.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ export class Rfc4RoomConnection implements RoomConnection {
1717

1818
private positionIndex: number = 0
1919

20-
constructor(private transport: MinimumCommunicationsAdapter, private id: string = '-') {
20+
constructor(private transport: MinimumCommunicationsAdapter, public id: string = '-') {
2121
this.transport.events.on('message', this.handleMessage.bind(this))
2222
this.transport.events.on('DISCONNECTION', (event) => this.events.emit('DISCONNECTION', event))
2323
this.transport.events.on('PEER_DISCONNECTED', (event) => this.events.emit('PEER_DISCONNECTED', event))
2424
}
2525

2626
async connect(): Promise<void> {
27-
console.log('[RoomConnection Comms]: connect', this.id)
27+
// console.log('[RoomConnection Comms]: connect', this.id)
2828
await this.transport.connect()
2929
}
3030

3131
createVoiceHandler(): Promise<VoiceHandler> {
32-
console.log('[RoomConnection Comms]: createVoiceHandler', this.id)
32+
// console.log('[RoomConnection Comms]: createVoiceHandler', this.id)
3333
return this.transport.createVoiceHandler()
3434
}
3535

3636
sendPositionMessage(p: Omit<proto.Position, 'index'>): Promise<void> {
37-
console.log('[RoomConnection Comms]: sendPositionMessage', this.id)
37+
// console.log('[RoomConnection Comms]: sendPositionMessage', this.id)
3838
return this.sendMessage(false, {
3939
message: {
4040
$case: 'position',
@@ -46,32 +46,32 @@ export class Rfc4RoomConnection implements RoomConnection {
4646
})
4747
}
4848
sendParcelSceneMessage(scene: proto.Scene): Promise<void> {
49-
console.log('[RoomConnection Comms]: sendParcelSceneMessage', this.id)
49+
// console.log('[RoomConnection Comms]: sendParcelSceneMessage', this.id)
5050
return this.sendMessage(false, { message: { $case: 'scene', scene } })
5151
}
5252
sendProfileMessage(profileVersion: proto.AnnounceProfileVersion): Promise<void> {
53-
console.log('[RoomConnection Comms]: sendProfileMessage', this.id)
53+
// console.log('[RoomConnection Comms]: sendProfileMessage', this.id)
5454
return this.sendMessage(false, { message: { $case: 'profileVersion', profileVersion } })
5555
}
5656
sendProfileRequest(profileRequest: proto.ProfileRequest): Promise<void> {
57-
console.log('[RoomConnection Comms]: sendProfileRequest', this.id)
57+
// console.log('[RoomConnection Comms]: sendProfileRequest', this.id)
5858
return this.sendMessage(false, { message: { $case: 'profileRequest', profileRequest } })
5959
}
6060
sendProfileResponse(profileResponse: proto.ProfileResponse): Promise<void> {
61-
console.log('[RoomConnection Comms]: sendProfileResponse', this.id)
61+
// console.log('[RoomConnection Comms]: sendProfileResponse', this.id)
6262
return this.sendMessage(false, { message: { $case: 'profileResponse', profileResponse } })
6363
}
6464
sendChatMessage(chat: proto.Chat): Promise<void> {
65-
console.log('[RoomConnection Comms]: sendChatMessage', this.id)
65+
// console.log('[RoomConnection Comms]: sendChatMessage', this.id)
6666
return this.sendMessage(true, { message: { $case: 'chat', chat } })
6767
}
6868
sendVoiceMessage(voice: proto.Voice): Promise<void> {
69-
console.log('[RoomConnection Comms]: sendVoiceMessage', this.id)
69+
// console.log('[RoomConnection Comms]: sendVoiceMessage', this.id)
7070
return this.sendMessage(false, { message: { $case: 'voice', voice } })
7171
}
7272

7373
async disconnect() {
74-
console.log('[RoomConnection Comms]: disconnect', this.id)
74+
// console.log('[RoomConnection Comms]: disconnect', this.id)
7575
await this.transport.disconnect()
7676
}
7777

@@ -82,7 +82,7 @@ export class Rfc4RoomConnection implements RoomConnection {
8282
return
8383
}
8484

85-
console.log('[RoomConnection Comms]: handleMessage', message.$case, this.id)
85+
// console.log('[RoomConnection Comms]: handleMessage', message.$case, this.id)
8686
switch (message.$case) {
8787
case 'position': {
8888
this.events.emit('position', { address, data: message.position })

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import { isBase64 } from 'lib/encoding/base64ToBlob'
5959
import { SET_PARCEL_POSITION } from 'shared/scene-loader/actions'
6060
import { getSceneLoader } from '../scene-loader/selectors'
6161
import { Vector2 } from '../protocol/decentraland/common/vectors.gen'
62+
import { DISABLE_SCENE_ROOM } from '../../config'
6263

6364
const TIME_BETWEEN_PROFILE_RESPONSES = 1000
6465
// this interval should be fast because this will be the delay other people around
@@ -266,7 +267,7 @@ async function connectAdapter(
266267
}
267268

268269
if (typeof response.fixedAdapter === 'string' && !response.fixedAdapter.startsWith('signed-login:')) {
269-
return connectAdapter(response.fixedAdapter, identity)
270+
return connectAdapter(response.fixedAdapter, identity, id)
270271
}
271272

272273
if (typeof response.message === 'string') {
@@ -546,6 +547,8 @@ function* sceneRoomComms() {
546547
let currentSceneId: string = ''
547548
const commsSceneToRemove = new Map<string, NodeJS.Timeout>()
548549

550+
if (DISABLE_SCENE_ROOM) return
551+
549552
while (true) {
550553
const reason: { timeout?: unknown; newParcel?: { payload: { position: Vector2 } } } = yield race({
551554
newParcel: take(SET_PARCEL_POSITION),
@@ -601,7 +604,8 @@ function* connectSceneToComms(sceneId: string) {
601604
const identity: ExplorerIdentity = yield select(getCurrentIdentity)
602605
// TODO: we should change the adapter control to provide this url
603606
const url = 'https://comms-gatekeeper.decentraland.zone/get-scene-adapter'
604-
const response = yield call(signedFetch,
607+
const response = yield call(
608+
signedFetch,
605609
url,
606610
identity,
607611
{ method: 'POST', responseBodyType: 'json' },

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export const getSceneRooms = (state: RootCommsState): Map<string, RoomConnection
2424
export const getCommsRoom = (state: RootCommsState): RoomConnection | undefined => {
2525
const islandRoom = state.comms.context
2626
const sceneRoom = state.comms.scene
27+
2728
if (!islandRoom) return undefined
29+
2830
return {
2931
connect: async () => {
3032
debugger
@@ -34,6 +36,8 @@ export const getCommsRoom = (state: RootCommsState): RoomConnection | undefined
3436
await islandRoom.disconnect()
3537
// TBD: should we disconnect from scenes here too ?
3638
},
39+
// TBD: This should be only be sent by the island ?
40+
// We may remove this before reach production, but to think about it
3741
sendProfileMessage: async (profile: AnnounceProfileVersion) => {
3842
const island = islandRoom.sendProfileMessage(profile)
3943
const scene = sceneRoom?.sendProfileMessage(profile)
@@ -55,22 +59,30 @@ export const getCommsRoom = (state: RootCommsState): RoomConnection | undefined
5559
await Promise.all([island, scene])
5660
},
5761
sendParcelSceneMessage: async (message: Scene) => {
58-
const island = islandRoom.sendParcelSceneMessage(message)
59-
const scene = sceneRoom?.sendParcelSceneMessage(message)
60-
await Promise.all([island, scene])
62+
if (message.sceneId !== sceneRoom?.id) {
63+
console.warn('Ignoring Scene Message', { sceneId: message.sceneId, connectedSceneId: sceneRoom?.id })
64+
return
65+
}
66+
// const island = islandRoom.sendParcelSceneMessage(message)
67+
await sceneRoom?.sendParcelSceneMessage(message)
6168
},
6269
sendChatMessage: async (message: Chat) => {
6370
const island = islandRoom.sendChatMessage(message)
6471
const scene = sceneRoom?.sendChatMessage(message)
6572
await Promise.all([island, scene])
6673
},
67-
sendVoiceMessage: async (_message: Voice) => {
68-
debugger
74+
// TBD: how voice chat works?
75+
sendVoiceMessage: async (message: Voice) => {
76+
if (!sceneRoom) debugger
77+
return sceneRoom!.sendVoiceMessage(message)
6978
},
7079
createVoiceHandler: async () => {
7180
// TBD: Feature flag for backwards compatibility
72-
if (!sceneRoom) debugger
73-
return sceneRoom!.createVoiceHandler()
81+
if (!sceneRoom) {
82+
debugger
83+
throw new Error('Scene room not avaialble')
84+
}
85+
return sceneRoom.createVoiceHandler()
7486
}
7587
} as any as RoomConnection
7688
}

0 commit comments

Comments
 (0)