diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 56d299b..579ea88 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@apiglobal/typedserver', - version: '2.0.44', + version: '2.0.45', description: 'easy serving of static files' } diff --git a/ts/interfaces/typedrequests.ts b/ts/interfaces/typedrequests.ts index 438736f..c088a2f 100644 --- a/ts/interfaces/typedrequests.ts +++ b/ts/interfaces/typedrequests.ts @@ -10,3 +10,14 @@ export interface IReq_PushLatestServerChangeTime extends typedrequestInterfaces. }; response: {} } + +export interface IReq_GetLatestServerChangeTime extends typedrequestInterfaces.implementsTR< + typedrequestInterfaces.ITypedRequest, + IReq_GetLatestServerChangeTime +> { + method: 'getLatestServerChangeTime', + request: {}; + response: { + time: number; + } +} diff --git a/ts/typedserver.classes.typedserver.ts b/ts/typedserver.classes.typedserver.ts index 20177c6..cc8da7d 100644 --- a/ts/typedserver.classes.typedserver.ts +++ b/ts/typedserver.classes.typedserver.ts @@ -176,6 +176,13 @@ export class TypedServer { this.server ); + // lets setup typedrouter + this.typedrouter.addTypedHandler(new plugins.typedrequest.TypedHandler('getLatestServerChangeTime', async reqDataArg => { + return { + time: this.lastReload, + } + })) + // console.log('open url in browser'); // await plugins.smartopen.openUrl(`http://testing.git.zone:${this.options.port}`); } diff --git a/ts_web/00_commitinfo_data.ts b/ts_web/00_commitinfo_data.ts index 56d299b..579ea88 100644 --- a/ts_web/00_commitinfo_data.ts +++ b/ts_web/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@apiglobal/typedserver', - version: '2.0.44', + version: '2.0.45', description: 'easy serving of static files' } diff --git a/ts_web/index.ts b/ts_web/index.ts index 9cf8bac..4e43a88 100644 --- a/ts_web/index.ts +++ b/ts_web/index.ts @@ -98,14 +98,18 @@ export class ReloadChecker { this.typedrouter, plugins.typedsocket.TypedSocket.useWindowLocationOriginUrl() ); - this.typedsocket.eventSubject.subscribe(eventArg => { + this.typedsocket.eventSubject.subscribe(async eventArg => { console.log(`typedsocket event subscription: ${eventArg}`); if (eventArg === 'disconnected' || eventArg === 'disconnecting' || eventArg === 'timedOut') { this.backendConnectionLost = true; this.infoscreen.setText(`typedsocket ${eventArg}!`) } else if (eventArg === 'connected' && this.backendConnectionLost) { this.backendConnectionLost = false; - this.infoscreen.setSuccess('typedsocket connected!') + this.infoscreen.setSuccess('typedsocket connected!'); + // lets check if a reload is necessary + const getLatestServerChangeTime = this.typedsocket.createTypedRequest('getLatestServerChangeTime'); + const response = await getLatestServerChangeTime.fire({}); + this.checkReload(response.time); } });