NODE JS introduction: socket polling
This commit is contained in:
@@ -7,6 +7,30 @@
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ── Real-time WebSocket connection ──────────────────────────────────────── -->
|
||||
<!-- Socket.io client is served by the Node.js server itself -->
|
||||
<script src="<?php echo NODE_PUBLIC_URL; ?>/socket.io/socket.io.js"></script>
|
||||
<script>
|
||||
(function () {
|
||||
// company_id is set in include_topbar.php as a JS global
|
||||
if (typeof company_id === 'undefined' || !company_id) return;
|
||||
|
||||
window._socket = io('<?php echo NODE_PUBLIC_URL; ?>', {
|
||||
query: { company_id: company_id },
|
||||
reconnection: true,
|
||||
reconnectionDelay: 2000,
|
||||
});
|
||||
|
||||
window._socket.on('connect', function () {
|
||||
console.log('[socket] connected', window._socket.id);
|
||||
});
|
||||
|
||||
window._socket.on('disconnect', function () {
|
||||
console.log('[socket] disconnected');
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- Stock rows modal — used by: order/order.php, order/return.php, po/po.php, po/supplier_returns.php (via show_stock_rows() in custom.js) -->
|
||||
<div class="modal fade" id="stock_rows_modal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg modal-dialog-scrollable">
|
||||
|
||||
Reference in New Issue
Block a user