initial commit

This commit is contained in:
root
2026-05-13 14:20:41 +00:00
commit 6e178d2012
6022 changed files with 399872 additions and 0 deletions
@@ -0,0 +1,22 @@
import { timing } from "./timing";
const DEFER_EVENT_LISTENER_TIME = 3000;
export const setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME) => {
if (keepAlive !== true) {
return -1;
}
const registerListener = () => {
if (request.socket) {
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
}
else {
request.on("socket", (socket) => {
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
});
}
};
if (deferTimeMs === 0) {
registerListener();
return 0;
}
return timing.setTimeout(registerListener, deferTimeMs);
};