feat: add socketSetKeepAlive api method
This commit is contained in:
parent
3dd34a9af2
commit
ac5877385b
20
src/index.ts
20
src/index.ts
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue