mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 11:01:54 +03:00
Fix love connection (#6275)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
ce9a30a3ff
commit
954a3bb9e7
@ -87,6 +87,8 @@ export class TParticipantInfo extends TDoc implements ParticipantInfo {
|
||||
|
||||
x!: number
|
||||
y!: number
|
||||
|
||||
sessionId!: string | null
|
||||
}
|
||||
|
||||
@Model(love.class.JoinRequest, core.class.Doc, DOMAIN_TRANSIENT)
|
||||
|
@ -337,13 +337,18 @@ export class ModelDb extends MemDb {
|
||||
}
|
||||
|
||||
protected async txUpdateDoc (tx: TxUpdateDoc<Doc>): Promise<TxResult> {
|
||||
const doc = this.getObject(tx.objectId) as any
|
||||
TxProcessor.updateDoc2Doc(doc, tx)
|
||||
return tx.retrieve === true ? { object: doc } : {}
|
||||
try {
|
||||
const doc = this.getObject(tx.objectId) as any
|
||||
TxProcessor.updateDoc2Doc(doc, tx)
|
||||
return tx.retrieve === true ? { object: doc } : {}
|
||||
} catch (err: any) {}
|
||||
return {}
|
||||
}
|
||||
|
||||
protected async txRemoveDoc (tx: TxRemoveDoc<Doc>): Promise<TxResult> {
|
||||
this.delDoc(tx.objectId)
|
||||
try {
|
||||
this.delDoc(tx.objectId)
|
||||
} catch (err: any) {}
|
||||
return {}
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,8 @@ export default plugin(presentationId, {
|
||||
Endpoint: '' as Metadata<string>,
|
||||
FrontUrl: '' as Asset,
|
||||
PreviewConfig: '' as Metadata<PreviewConfig | undefined>,
|
||||
ClientHook: '' as Metadata<ClientHook>
|
||||
ClientHook: '' as Metadata<ClientHook>,
|
||||
SessionId: '' as Metadata<string>
|
||||
},
|
||||
status: {
|
||||
FileTooLarge: '' as StatusCode
|
||||
|
@ -261,7 +261,7 @@ class Connection implements ClientConnection {
|
||||
|
||||
void this.opt?.onConnect?.(
|
||||
(resp as HelloResponse).reconnect === true ? ClientConnectEvent.Reconnected : ClientConnectEvent.Connected,
|
||||
null
|
||||
this.sessionId
|
||||
)
|
||||
this.schedulePing(socketId)
|
||||
return
|
||||
|
@ -72,9 +72,12 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
})
|
||||
},
|
||||
// We need to refresh all active live queries and clear old queries.
|
||||
onConnect: (event: ClientConnectEvent) => {
|
||||
onConnect: (event: ClientConnectEvent, data: any) => {
|
||||
console.log('WorkbenchClient: onConnect', event)
|
||||
try {
|
||||
if (event === ClientConnectEvent.Connected) {
|
||||
setMetadata(presentation.metadata.SessionId, data)
|
||||
}
|
||||
if ((_clientSet && event === ClientConnectEvent.Connected) || event === ClientConnectEvent.Refresh) {
|
||||
void refreshClient(true)
|
||||
}
|
||||
|
@ -57,7 +57,6 @@
|
||||
rooms
|
||||
} from '../stores'
|
||||
import {
|
||||
connectRoom,
|
||||
disconnect,
|
||||
getRoomName,
|
||||
isCameraEnabled,
|
||||
|
@ -43,6 +43,7 @@
|
||||
} from '../utils'
|
||||
import ControlBar from './ControlBar.svelte'
|
||||
import ParticipantView from './ParticipantView.svelte'
|
||||
import presentation from '@hcengineering/presentation'
|
||||
|
||||
export let withVideo: boolean
|
||||
export let room: TypeRoom
|
||||
@ -223,7 +224,11 @@
|
||||
|
||||
await $storePromise
|
||||
|
||||
if (!$isConnected && !$isCurrentInstanceConnected) {
|
||||
if (
|
||||
!$isConnected &&
|
||||
!$isCurrentInstanceConnected &&
|
||||
$myInfo?.sessionId === getMetadata(presentation.metadata.SessionId)
|
||||
) {
|
||||
const info = $infos.filter((p) => p.room === room._id)
|
||||
await tryConnect($personByIdStore, $myInfo, room, info, $myRequests, $invites)
|
||||
}
|
||||
|
@ -485,14 +485,16 @@ async function moveToRoom (
|
||||
y: number,
|
||||
currentInfo: ParticipantInfo | undefined,
|
||||
currentPerson: Person,
|
||||
room: Room
|
||||
room: Room,
|
||||
sessionId: string | null
|
||||
): Promise<void> {
|
||||
const client = getClient()
|
||||
if (currentInfo !== undefined) {
|
||||
await client.diffUpdate(currentInfo, {
|
||||
x,
|
||||
y,
|
||||
room: room._id
|
||||
room: room._id,
|
||||
sessionId
|
||||
})
|
||||
} else {
|
||||
await client.createDoc(love.class.ParticipantInfo, core.space.Workspace, {
|
||||
@ -500,7 +502,8 @@ async function moveToRoom (
|
||||
y,
|
||||
room: room._id,
|
||||
person: currentPerson._id,
|
||||
name: currentPerson.name
|
||||
name: currentPerson.name,
|
||||
sessionId
|
||||
})
|
||||
}
|
||||
const loc = getCurrentLocation()
|
||||
@ -529,7 +532,7 @@ export async function connectRoom (
|
||||
room: Room
|
||||
): Promise<void> {
|
||||
await disconnect()
|
||||
await moveToRoom(x, y, currentInfo, currentPerson, room)
|
||||
await moveToRoom(x, y, currentInfo, currentPerson, room, getMetadata(presentation.metadata.SessionId) ?? null)
|
||||
await connectLK(currentPerson, room)
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ export interface ParticipantInfo extends Doc {
|
||||
room: Ref<Room>
|
||||
x: number
|
||||
y: number
|
||||
sessionId: string | null
|
||||
}
|
||||
|
||||
export interface RoomInfo extends Doc {
|
||||
|
@ -168,6 +168,9 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (event === ClientConnectEvent.Connected) {
|
||||
setMetadata(presentation.metadata.SessionId, data)
|
||||
}
|
||||
if ((_clientSet && event === ClientConnectEvent.Connected) || event === ClientConnectEvent.Refresh) {
|
||||
void ctx.with('refresh client', {}, async () => {
|
||||
await refreshClient(tokenChanged)
|
||||
|
@ -84,7 +84,8 @@ async function createUserInfo (acc: Ref<Account>, control: TriggerControl): Prom
|
||||
name: person !== undefined ? getName(control.hierarchy, person, control.branding?.lastNameFirst) : account.email,
|
||||
room: room?._id ?? love.ids.Reception,
|
||||
x: 0,
|
||||
y: 0
|
||||
y: 0,
|
||||
sessionId: null
|
||||
})
|
||||
const ptx = control.txFactory.createTxApplyIf(
|
||||
core.space.Workspace,
|
||||
@ -93,7 +94,7 @@ async function createUserInfo (acc: Ref<Account>, control: TriggerControl): Prom
|
||||
[
|
||||
{
|
||||
_class: love.class.ParticipantInfo,
|
||||
query: { person }
|
||||
query: { person: personId }
|
||||
}
|
||||
],
|
||||
[tx],
|
||||
|
Loading…
Reference in New Issue
Block a user