websocket-gateway copy updates to init

This commit is contained in:
Nuwan 2024-03-16 22:53:15 +05:30
parent 0476e5ebb6
commit 2459b3d447
1 changed files with 12 additions and 5 deletions

View File

@ -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}"