feat: add socketSetKeepAlive api method

This commit is contained in:
Derrick Hammer 2023-07-23 14:36:27 -04:00
parent 3dd34a9af2
commit ac5877385b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 20 additions and 0 deletions

View File

@ -82,6 +82,7 @@ addHandler("socketListenEvent", handleSocketListenEvent, {
addHandler("socketListeners", handleSocketListenersEvent); addHandler("socketListeners", handleSocketListenersEvent);
addHandler("socketWrite", handleWriteSocketEvent); addHandler("socketWrite", handleWriteSocketEvent);
addHandler("socketClose", handleCloseSocketEvent); addHandler("socketClose", handleCloseSocketEvent);
addHandler("socketSetKeepAlive", handleSocketSetKeepAliveEvent);
addHandler("createProtomuxChannel", handleCreateProtomuxChannel, { addHandler("createProtomuxChannel", handleCreateProtomuxChannel, {
receiveUpdates: true, receiveUpdates: true,
}); });
@ -240,6 +241,25 @@ function handleCloseSocketEvent(aq: ActiveQuery) {
aq.respond(); aq.respond();
} }
function handleSocketSetKeepAliveEvent(aq: ActiveQuery) {
const socket = validateConnection(aq);
if (!socket) {
return;
}
const { alive = null } = aq.callerInput;
if (!alive) {
aq.reject("alive required");
return;
}
socket.setKeepAlive(aq.callerInput.alive);
aq.respond();
}
async function handleWriteSocketEvent(aq: ActiveQuery) { async function handleWriteSocketEvent(aq: ActiveQuery) {
const socket = validateConnection(aq); const socket = validateConnection(aq);