From 2459b3d4474aca75737af6ff13862d6d9abccca0 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Sat, 16 Mar 2024 22:53:15 +0530 Subject: [PATCH] websocket-gateway copy updates to init --- websocket-gateway/lib/jam_websockets/router.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/websocket-gateway/lib/jam_websockets/router.rb b/websocket-gateway/lib/jam_websockets/router.rb index 5aecbe467..5f1d5a740 100644 --- a/websocket-gateway/lib/jam_websockets/router.rb +++ b/websocket-gateway/lib/jam_websockets/router.rb @@ -95,7 +95,8 @@ module JamWebsockets # this thread runs forever while WSG runs, and should do anything easily gotten out of critical message handling path @background_thread = Thread.new { - count = 0 + client_check_count = 0 + user_last_seen_count = 0 while true @@ -103,11 +104,17 @@ module JamWebsockets periodical_check_connections periodical_notification_seen - if count == 30 + if client_check_count == 30 periodical_check_clients - count = 0 + client_check_count = 0 end - count = count + 1 + client_check_count = client_check_count + 1 + + if user_last_seen_count == 120 + periodical_update_user_last_seen + user_last_seen_count = 0 + end + user_last_seen_count = user_last_seen_count + 1 rescue => e @log.error "unhandled error in thread #{e}" @@ -116,7 +123,7 @@ module JamWebsockets sleep 1 end } - end + end def start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, options={:host => "localhost", :port => 5672, :max_connections_per_user => 10, :gateway => 'default', :allow_dynamic_registration => true, :chat_enabled => true, :chat_blast => true}, &block)