Clean up sync room socket handling

This commit is contained in:
SrGooglo 2025-06-16 20:46:58 +00:00
parent 0f70bf43fd
commit 5d3dbeb6da

View File

@ -72,6 +72,8 @@ export default class SyncRoom {
track_manifest = { track_manifest = {
...currentItem.toSeriableObject(), ...currentItem.toSeriableObject(),
} }
delete track_manifest.source
} }
// check if has changed the track // check if has changed the track
@ -98,8 +100,6 @@ export default class SyncRoom {
} }
syncState = async (data) => { syncState = async (data) => {
console.log(data)
if (!data || !data.track_manifest) { if (!data || !data.track_manifest) {
return false return false
} }
@ -129,11 +129,12 @@ export default class SyncRoom {
const currentTime = this.player.seek() const currentTime = this.player.seek()
const offset = serverTime - currentTime const offset = serverTime - currentTime
console.log({ this.player.console.debug("sync_state", {
serverPayload: data,
serverTime: serverTime, serverTime: serverTime,
currentTime: currentTime, currentTime: currentTime,
maxTimeOffset: SyncRoom.maxTimeOffset,
offset: offset, offset: offset,
maxTimeOffset: SyncRoom.maxTimeOffset,
}) })
if ( if (
@ -182,13 +183,13 @@ export default class SyncRoom {
this.state.joined_room = null this.state.joined_room = null
if (this.socket) { if (this.socket) {
await this.socket.disconnect() await this.socket.destroy()
} }
} }
createSocket = async () => { createSocket = async () => {
if (this.socket) { if (this.socket) {
await this.socket.disconnect() await this.socket.destroy()
} }
this.socket = new RTEngineClient({ this.socket = new RTEngineClient({