Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
22 lines
710 B
Text
22 lines
710 B
Text
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);
|
|
};
|