From c448d876b597e6b96f08a9c75e781e2b53ad4456 Mon Sep 17 00:00:00 2001 From: Rolands Date: Tue, 6 Jan 2026 12:01:35 +0200 Subject: [PATCH] SERV auto responds with return truthy val --- core/core-server.ts | 8 ++++++-- core/package-lock.json | 4 ++-- core/package.json | 2 +- core/types.d.ts | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/core-server.ts b/core/core-server.ts index 3c60a17..bdcf78c 100644 --- a/core/core-server.ts +++ b/core/core-server.ts @@ -498,8 +498,12 @@ export class SocioServer extends LogHandler { break; } case ServerMessageKind.SERV: { - if (this.lifecycle_hooks.serv) - await this.lifecycle_hooks.serv(client, data); + if (this.lifecycle_hooks.serv){ + const res = await this.lifecycle_hooks.serv(client, data); + if (res !== undefined){ + client.Send(ClientMessageKind.RES, { id: data?.id, result: { success: 1, res } } as C_RES_data); + } + } else throw new E('Client sent generic data to the server, but the hook for it is not registed. [#no-serv-hook]', client_id); break; } diff --git a/core/package-lock.json b/core/package-lock.json index 39ebf3f..a820536 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "socio", - "version": "1.15.5", + "version": "1.15.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "socio", - "version": "1.15.5", + "version": "1.15.6", "license": "MIT", "dependencies": { "@msgpack/msgpack": "^3.1.2", diff --git a/core/package.json b/core/package.json index ec50c33..943a603 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "socio", - "version": "1.15.5", + "version": "1.15.6", "description": "A WebSocket Real-Time Communication (RTC) API framework.", "main": "./dist/core.js", "type": "module", diff --git a/core/types.d.ts b/core/types.d.ts index a9945db..b9dcce7 100644 --- a/core/types.d.ts +++ b/core/types.d.ts @@ -39,7 +39,7 @@ type ServerHookDefinitions = { auth?: (caller_client: SocioSession, params: object | null) => boolean | Promise, gen_client_id?: () => ClientID | Promise, grant_perm?: (caller_client: SocioSession, data: GET_PERM_data) => boolean | Promise, - serv?: (caller_client: SocioSession, data: MessageDataObj) => void | Promise, + serv?: (caller_client: SocioSession, data: MessageDataObj) => any | Promise, admin?: (caller_client: SocioSession, data: MessageDataObj) => boolean | Promise, blob?: (caller_client: SocioSession, request: Buffer | ArrayBuffer | Buffer[]) => boolean | Promise, file_upload?: (caller_client: SocioSession, files?: SocioFiles, data?: any) => Bit | boolean | Promise,