Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function setupLiveShare(windowManager: BrowserViewWindowManager) {
const liveShare = await vsls.getApi();
if (!liveShare) {
// The user doesn't have the Live Share
// extension installed, so there's nothing
// further to initialize.
return;
}
await sessionStarted(liveShare);
setupServices(liveShare, windowManager);
}
async function initializeLiveshare() {
const liveshare = await vsls.getApi();
if (liveshare) {
// {access: number, id: string, peerNumber: number, role: number, user: json}
logIt(`liveshare version - ${liveshare["apiVersion"]}`);
liveshare.onDidChangeSession(async event => {
let nowSec = nowInSecs();
let offsetSec = getOffsetSecends();
let localNow = nowSec - offsetSec;
if (!_ls) {
_ls = {
...event.session
};
_ls["apiVesion"] = liveshare["apiVersion"];
_ls["start"] = nowSec;
_ls["local_start"] = localNow;
_ls["end"] = 0;
private onSettingsChanged() {
const supported = this.configService.getSettings().datascience.allowLiveShare;
if (supported !== this.supported) {
this.supported = supported ? true : false;
const liveShareTimeout = this.configService.getSettings().datascience.liveShareConnectionTimeout;
this.apiPromise = supported ?
vsls.getApi().then(a => a ? new LiveShareProxy(this.appShell, liveShareTimeout, a) : a) :
Promise.resolve(null);
} else if (!this.apiPromise) {
this.apiPromise = Promise.resolve(null);
}
}
}