🔧 Added namespace option to socket endpoint calls

This commit is contained in:
2024-07-10 14:35:49 -04:00
parent e7341b553d
commit aff4467b8b
2 changed files with 52 additions and 68 deletions

View File

@@ -122,6 +122,7 @@ export default class SocketService extends Service {
params: {
query: "object",
config: "object",
namespace: "string",
},
async handler(ctx) {
const { query, config, namespace } = ctx.params;
@@ -183,6 +184,9 @@ export default class SocketService extends Service {
await ADCPPSocket.get(
`search/${instance.id}`
);
console.log(
JSON.stringify(currentInstance, null, 4)
);
// Send the instance to the client
await namespacedInstance.emit(
"searchesSent",
@@ -190,6 +194,7 @@ export default class SocketService extends Service {
searchInfo,
}
);
if (currentInstance.result_count === 0) {
console.log("No more search results.");
namespacedInstance.emit(
@@ -197,6 +202,7 @@ export default class SocketService extends Service {
{
message:
"No more search results.",
currentInstance,
}
);
}
@@ -221,7 +227,7 @@ export default class SocketService extends Service {
{ error }
);
} finally {
// await ADCPPSocket.disconnect();
await ADCPPSocket.disconnect();
}
},
},