client: timing

This commit is contained in:
Koushik Dutta
2022-09-14 20:11:08 -07:00
parent f396d55ddc
commit ba82dbb4c8
4 changed files with 39 additions and 27 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/client",
"version": "1.0.55",
"version": "1.0.57",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/client",
"version": "1.0.55",
"version": "1.0.57",
"license": "ISC",
"dependencies": {
"@scrypted/types": "^0.0.88",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/client",
"version": "1.0.55",
"version": "1.0.57",
"description": "",
"main": "dist/packages/client/src/index.js",
"scripts": {

View File

@@ -146,6 +146,7 @@ export async function redirectScryptedLogout(baseUrl?: string) {
}
export async function connectScryptedClient(options: ScryptedClientOptions): Promise<ScryptedClientStatic> {
const start = Date.now();
let { baseUrl, pluginId, clientName, username, password } = options;
const extraHeaders: { [header: string]: string } = {};
@@ -158,6 +159,7 @@ export async function connectScryptedClient(options: ScryptedClientOptions): Pro
extraHeaders['Authorization'] = loginResult.authorization;
addresses = loginResult.addresses;
scryptedCloud = loginResult.scryptedCloud;
console.log('login result', loginResult);
}
else {
const loginCheck = await checkScryptedClientLogin({
@@ -167,6 +169,7 @@ export async function connectScryptedClient(options: ScryptedClientOptions): Pro
throw new ScryptedClientLoginError(loginCheck);
addresses = loginCheck.addresses;
scryptedCloud = loginCheck.scryptedCloud;
console.log('login checked', loginCheck);
}
let socket: IOClientSocket;
@@ -177,8 +180,6 @@ export async function connectScryptedClient(options: ScryptedClientOptions): Pro
rejectUnauthorized: false,
};
const start = Date.now();
const explicitBaseUrl = baseUrl || `${globalThis.location.protocol}//${globalThis.location.host}`;
let connectionType: ScryptedClientConnectionType;
@@ -359,7 +360,7 @@ export async function connectScryptedClient(options: ScryptedClientOptions): Pro
});
if (isTimedOut()) {
console.log('peer connection established too late. closing.');
console.log('peer connection established too late. closing.', Date.now() - start);
ready.close();
}
else {
@@ -373,7 +374,7 @@ export async function connectScryptedClient(options: ScryptedClientOptions): Pro
sockets = sockets.filter(s => s !== socket);
}
catch (e) {
console.error('peer to peer failed', e);
console.error('peer to peer failed', Date.now() - start, e);
}
sockets.forEach(s => {
try {
@@ -424,27 +425,38 @@ export async function connectScryptedClient(options: ScryptedClientOptions): Pro
endpointManager,
mediaManager,
} = scrypted;
const userStorage = await rpcPeer.getParam('userStorage');
const info = await systemManager.getComponent('info');
let version = 'unknown';
try {
version = await info.getVersion();
}
catch (e) {
}
console.log('api attached', Date.now() - start);
const { browserSignalingSession, connectionManagementId } = rpcPeer.params;
let rtcConnectionManagement: RTCConnectionManagement;
if (connectionManagementId) {
try {
const plugins = await systemManager.getComponent('plugins');
rtcConnectionManagement = await plugins.getHostParam('@scrypted/webrtc', connectionManagementId);
}
catch (e) {
}
}
const [userStorage, version, rtcConnectionManagement] = await Promise.all([
rpcPeer.getParam('userStorage'),
(async () => {
const info = await systemManager.getComponent('info');
let version = 'unknown';
try {
version = await info.getVersion();
}
catch (e) {
}
return version;
})(),
(async () => {
let rtcConnectionManagement: RTCConnectionManagement;
if (connectionManagementId) {
try {
const plugins = await systemManager.getComponent('plugins');
rtcConnectionManagement = await plugins.getHostParam('@scrypted/webrtc', connectionManagementId);
return rtcConnectionManagement;
}
catch (e) {
}
}
})(),
]);
console.log('api initialized', Date.now() - start);
console.log('api queried, version:', version);
const ret: ScryptedClientStatic = {
pluginRemoteAPI: undefined,