Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
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
1 change: 1 addition & 0 deletions packages/client-core/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"loadingAllowed": "Loading allowed routes...",
"loadingXRSystems": "Loading immersive session...",
"connectingToWorld": "Connecting to world...",
"connectingToMedia": "Connecting to media...",
"entering": "Entering world...",
"loading": "Loading...",
"objectRemaining": "{{count}} object remaining",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export const MediaInstanceState = defineState({
name: 'MediaInstanceState',
initial: () => ({
instances: {} as { [id: string]: InstanceState },
joiningNonInstanceMediaChannel: false
joiningNonInstanceMediaChannel: false,
joiningNewMediaChannel: false
})
})

Expand Down Expand Up @@ -93,6 +94,7 @@ export const MediaInstanceConnectionServiceReceptor = (action) => {
})
.when(MediaInstanceConnectionAction.serverConnected.matches, (action) => {
s.joiningNonInstanceMediaChannel.set(false)
s.joiningNewMediaChannel.set(false)
return s.instances[action.instanceId].merge({
connected: true,
connecting: false,
Expand All @@ -107,7 +109,8 @@ export const MediaInstanceConnectionServiceReceptor = (action) => {
.when(MediaInstanceConnectionAction.disconnect.matches, (action) => {
return s.instances[action.instanceId].set(none)
})
.when(MediaInstanceConnectionAction.joiningNonInstanceMediaChannel.matches, (action) => {
.when(MediaInstanceConnectionAction.joiningNonInstanceMediaChannel.matches, () => {
s.joiningNewMediaChannel.set(true)
return s.joiningNonInstanceMediaChannel.set(true)
})
.when(MediaInstanceConnectionAction.changeActiveConnectionHostId.matches, (action) => {
Expand All @@ -119,6 +122,9 @@ export const MediaInstanceConnectionServiceReceptor = (action) => {
s.instances.merge({ [action.newInstanceId]: currentNetwork })
s.instances[action.currentInstanceId].set(none)
})
.when(MediaInstanceConnectionAction.joiningNewMediaChannel.matches, () => {
return s.joiningNewMediaChannel.set(true)
})
}

//Service
Expand Down Expand Up @@ -203,6 +209,9 @@ export const MediaInstanceConnectionService = {
Engine.instance.api.service('instance-provision').off('created', listener)
}
}, [])
},
setJoining: (joining: boolean) => {
dispatchAction(MediaInstanceConnectionAction.joiningNewMediaChannel({}))
}
}

Expand Down Expand Up @@ -243,6 +252,10 @@ export class MediaInstanceConnectionAction {
type: 'ee.client.MediaInstanceConnection.JOINING_NON_INSTANCE_MEDIA_CHANNEL' as const
})

static joiningNewMediaChannel = defineAction({
type: 'ee.client.MediaInstanceConnection.JOINING_NEW_MEDIA_CHANNEL' as const
})

static changeActiveConnectionHostId = defineAction({
type: 'ee.client.MediaInstanceConnection.MEDIA_INSTANCE_SERVER_CHANGE_HOST_ID' as const,
currentInstanceId: matchesUserId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@
flex-direction: column;
}
}

.loader {
display: flex;
padding: 0;
align-items: center;
text-align: center;
margin: 5px;
}
18 changes: 18 additions & 0 deletions packages/client-core/src/components/MediaIconsBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { t } from 'i18next'
import React, { useEffect } from 'react'
import { useLocation } from 'react-router-dom'

Expand All @@ -15,6 +16,7 @@ import { EngineActions, EngineState } from '@etherealengine/engine/src/ecs/class
import { NetworkState } from '@etherealengine/engine/src/networking/NetworkState'
import { XRAction, XRState } from '@etherealengine/engine/src/xr/XRState'
import { dispatchAction, getMutableState, useHookstate } from '@etherealengine/hyperflux'
import CircularProgress from '@etherealengine/ui/src/primitives/mui/CircularProgress'
import Icon from '@etherealengine/ui/src/primitives/mui/Icon'

import { VrIcon } from '../../common/components/Icons/VrIcon'
Expand Down Expand Up @@ -69,6 +71,22 @@ export const MediaIconsBox = () => {

return (
<section className={`${styles.drawerBox} ${topShelfStyle}`}>
{(currentChannelInstanceConnection == null || !currentChannelInstanceConnection?.connected.value) && (
<div className={styles.loader}>
<CircularProgress />
<div
style={{
// default values will be overridden by theme
fontFamily: 'Lato',
fontSize: '12px',
color: '#585858',
padding: '16px'
}}
>
{t('common:loader.connectingToMedia') as string}
</div>
</div>
)}
{audioEnabled &&
hasAudioDevice.value &&
mediaNetworkReady &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
MediaInstanceConnectionService,
MediaInstanceConnectionServiceReceptor
} from '../common/services/MediaInstanceConnectionService'
import { MediaInstanceState } from '../common/services/MediaInstanceConnectionService'
import { NetworkConnectionService } from '../common/services/NetworkConnectionService'
import { DataChannels } from '../components/World/ProducersAndConsumers'
import { PeerConsumers } from '../media/PeerMedia'
Expand Down Expand Up @@ -100,6 +101,7 @@ const execute = () => {

for (const action of mediaInstanceDisconnectedQueue()) {
const transport = Engine.instance.mediaNetwork as SocketWebRTCClientNetwork
const mediaInstanceState = getState(MediaInstanceState)
if (transport?.reconnecting) continue

const channels = chatState.channels.channels
Expand All @@ -108,7 +110,7 @@ const execute = () => {
(channel) => channel.channelType === 'party' && channel.partyId === authState.user.partyId
)
const channelId = partyChannel ? partyChannel.id : instanceChannel ? instanceChannel.id : null
if (channelId)
if (channelId && !mediaInstanceState.joiningNewMediaChannel)
WarningUIService.openWarning({
title: 'Media disconnected',
body: "You've lost your connection with the media server. We'll try to reconnect when the following time runs out.",
Expand Down
5 changes: 2 additions & 3 deletions packages/client-core/src/social/services/PartyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,10 @@ export const PartyService = {
},
createParty: async () => {
try {
MediaInstanceConnectionService.setJoining(true)
const network = Engine.instance.mediaNetwork as SocketWebRTCClientNetwork
console.log('ending video chat')
await endVideoChat(network, {})
console.log('ended video chat, now leaving network')
await leaveNetwork(network)
console.log('left network, making party')
await Engine.instance.api.service('party').create()
PartyService.getParty()
} catch (err) {
Expand Down Expand Up @@ -205,6 +203,7 @@ export const PartyService = {
const instanceChannel = Object.values(channels).find(
(channel) => channel.instanceId === Engine.instance.worldNetwork?.hostId
)
MediaInstanceConnectionService.setJoining(true)
if (instanceChannel) await MediaInstanceConnectionService.provisionServer(instanceChannel?.id!, true)
}
},
Expand Down