livekit-client
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -16,3 +16,4 @@ import type { RegionSettings } from '@livekit/protocol'; | ||
fetchRegionSettings(signal?: AbortSignal): Promise<RegionSettings>; | ||
setServerReportedRegions(regions: RegionSettings): void; | ||
} | ||
//# sourceMappingURL=RegionUrlProvider.d.ts.map |
@@ -143,5 +143,8 @@ import { AudioTrackFeature, StreamState as ProtoStreamState, TrackSource, TrackType } from '@livekit/protocol'; | ||
audioTrackFeatureUpdate: (track: any, feature: AudioTrackFeature, enabled: boolean) => void; | ||
timeSyncUpdate: (timestamp: number) => void; | ||
timeSyncUpdate: (update: { | ||
timestamp: number; | ||
rtpTimestamp: number; | ||
}) => void; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=Track.d.ts.map |
export declare const version: string; | ||
export declare const protocolVersion = 12; | ||
export declare const protocolVersion = 13; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -16,3 +16,4 @@ import type { RegionSettings } from '@livekit/protocol'; | ||
fetchRegionSettings(signal?: AbortSignal): Promise<RegionSettings>; | ||
setServerReportedRegions(regions: RegionSettings): void; | ||
} | ||
//# sourceMappingURL=RegionUrlProvider.d.ts.map |
@@ -143,5 +143,8 @@ import { AudioTrackFeature, StreamState as ProtoStreamState, TrackSource, TrackType } from '@livekit/protocol'; | ||
audioTrackFeatureUpdate: (track: any, feature: AudioTrackFeature, enabled: boolean) => void; | ||
timeSyncUpdate: (timestamp: number) => void; | ||
timeSyncUpdate: (update: { | ||
timestamp: number; | ||
rtpTimestamp: number; | ||
}) => void; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=Track.d.ts.map |
export declare const version: string; | ||
export declare const protocolVersion = 12; | ||
export declare const protocolVersion = 13; | ||
//# sourceMappingURL=version.d.ts.map |
{ | ||
"name": "livekit-client", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "JavaScript/TypeScript client SDK for LiveKit", | ||
@@ -5,0 +5,0 @@ "main": "./dist/livekit-client.umd.js", |
@@ -9,2 +9,3 @@ import { | ||
LeaveRequest, | ||
LeaveRequest_Action, | ||
MuteTrackRequest, | ||
@@ -600,4 +601,5 @@ ParticipantInfo, | ||
value: new LeaveRequest({ | ||
canReconnect: false, | ||
reason: DisconnectReason.CLIENT_INITIATED, | ||
// server doesn't process this field, keeping it here to indicate the intent of a full disconnect | ||
action: LeaveRequest_Action.DISCONNECT, | ||
}), | ||
@@ -604,0 +606,0 @@ }); |
@@ -78,2 +78,7 @@ import type { RegionInfo, RegionSettings } from '@livekit/protocol'; | ||
} | ||
setServerReportedRegions(regions: RegionSettings) { | ||
this.regionSettings = regions; | ||
this.lastUpdateAt = Date.now(); | ||
} | ||
} | ||
@@ -80,0 +85,0 @@ |
@@ -12,2 +12,3 @@ import { | ||
type LeaveRequest, | ||
LeaveRequest_Action, | ||
ParticipantInfo, | ||
@@ -439,3 +440,5 @@ ReconnectReason, | ||
this.createDataChannels(); | ||
if (!supportOptionalDatachannel(joinResponse.serverInfo?.protocol)) { | ||
this.createDataChannels(); | ||
} | ||
} | ||
@@ -509,12 +512,24 @@ | ||
this.client.onLeave = (leave?: LeaveRequest) => { | ||
if (leave?.canReconnect) { | ||
this.fullReconnectOnNext = true; | ||
// reconnect immediately instead of waiting for next attempt | ||
this.handleDisconnect(leaveReconnect); | ||
} else { | ||
this.emit(EngineEvent.Disconnected, leave?.reason); | ||
this.close(); | ||
this.client.onLeave = (leave: LeaveRequest) => { | ||
this.log.debug('client leave request', { ...this.logContext, reason: leave?.reason }); | ||
if (leave.regions && this.regionUrlProvider) { | ||
this.log.debug('updating regions', this.logContext); | ||
this.regionUrlProvider.setServerReportedRegions(leave.regions); | ||
} | ||
this.log.debug('client leave request', { ...this.logContext, reason: leave?.reason }); | ||
switch (leave.action) { | ||
case LeaveRequest_Action.DISCONNECT: | ||
this.emit(EngineEvent.Disconnected, leave?.reason); | ||
this.close(); | ||
break; | ||
case LeaveRequest_Action.RECONNECT: | ||
this.fullReconnectOnNext = true; | ||
// reconnect immediately instead of waiting for next attempt | ||
this.handleDisconnect(leaveReconnect); | ||
break; | ||
case LeaveRequest_Action.RESUME: | ||
// reconnect immediately instead of waiting for next attempt | ||
this.handleDisconnect(leaveReconnect); | ||
default: | ||
break; | ||
} | ||
}; | ||
@@ -1109,3 +1124,10 @@ } | ||
let needNegotiation = false; | ||
if (!subscriber && !this.dataChannelForKind(kind, subscriber)) { | ||
this.createDataChannels(); | ||
needNegotiation = true; | ||
} | ||
if ( | ||
!needNegotiation && | ||
!subscriber && | ||
@@ -1115,2 +1137,5 @@ !this.pcManager.publisher.isICEConnected && | ||
) { | ||
needNegotiation = true; | ||
} | ||
if (needNegotiation) { | ||
// start negotiation | ||
@@ -1176,2 +1201,10 @@ this.negotiate(); | ||
this.pcManager.requirePublisher(); | ||
// don't negotiate without any transceivers or data channel, it will generate sdp without ice frag then negotiate failed | ||
if ( | ||
this.pcManager.publisher.getTransceivers().length == 0 && | ||
!this.lossyDC && | ||
!this.reliableDC | ||
) { | ||
this.createDataChannels(); | ||
} | ||
@@ -1387,1 +1420,5 @@ const abortController = new AbortController(); | ||
}; | ||
function supportOptionalDatachannel(protocol: number | undefined): boolean { | ||
return protocol !== undefined && protocol > 13; | ||
} |
@@ -88,6 +88,9 @@ import { TrackEvent } from '../events'; | ||
this.timeSyncHandle = requestAnimationFrame(() => loop()); | ||
const newTime = this.receiver?.getSynchronizationSources()[0]?.rtpTimestamp; | ||
if (newTime && this.rtpTimestamp !== newTime) { | ||
this.emit(TrackEvent.TimeSyncUpdate, newTime); | ||
this.rtpTimestamp = newTime; | ||
const sources = this.receiver?.getSynchronizationSources()[0]; | ||
if (sources) { | ||
const { timestamp, rtpTimestamp } = sources; | ||
if (rtpTimestamp && this.rtpTimestamp !== rtpTimestamp) { | ||
this.emit(TrackEvent.TimeSyncUpdate, { timestamp, rtpTimestamp }); | ||
this.rtpTimestamp = rtpTimestamp; | ||
} | ||
} | ||
@@ -94,0 +97,0 @@ }; |
@@ -528,3 +528,3 @@ import { | ||
audioTrackFeatureUpdate: (track: any, feature: AudioTrackFeature, enabled: boolean) => void; | ||
timeSyncUpdate: (timestamp: number) => void; | ||
timeSyncUpdate: (update: { timestamp: number; rtpTimestamp: number }) => void; | ||
}; |
import { version as v } from '../package.json'; | ||
export const version = v; | ||
export const protocolVersion = 12; | ||
export const protocolVersion = 13; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
5463859
48872