Added ajax session last ping to not expire valid sessions.
This commit is contained in:
parent
e74619dba4
commit
9cdd2a94ea
|
@ -70,15 +70,17 @@ class LongPollingController < ApplicationController
|
||||||
if params['data']['data']['recipient'] && params['data']['data']['recipient']['user_id']
|
if params['data']['data']['recipient'] && params['data']['data']['recipient']['user_id']
|
||||||
params['data']['data']['recipient']['user_id'].each { |user_id|
|
params['data']['data']['recipient']['user_id'].each { |user_id|
|
||||||
if local_client[:user][:id] == user_id
|
if local_client[:user][:id] == user_id
|
||||||
log 'notice', "send broadcast (user_id #{user_id})", local_client_id
|
log 'notice', "send broadcast from (#{client_id.to_s}) to (user_id #{user_id})", local_client_id
|
||||||
Session.send( local_client_id, params['data'] )
|
Session.send( local_client_id, params['data'] )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
# broadcast every client
|
# broadcast every client
|
||||||
else
|
else
|
||||||
log 'notice', "send broadcast", local_client_id
|
log 'notice', "send broadcast from (#{client_id.to_s})", local_client_id
|
||||||
Session.send( local_client_id, params['data'] )
|
Session.send( local_client_id, params['data'] )
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
log 'notice', "do not send broadcast to it self", client_id
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -100,10 +102,13 @@ class LongPollingController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# check queue queue to send
|
# check queue to send
|
||||||
client_id = client_id_check
|
client_id = client_id_check
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
# update last ping
|
||||||
|
Session.touch( client_id )
|
||||||
|
|
||||||
# set max loop time to 28 sec. because of 30 sec. timeout of mod_proxy
|
# set max loop time to 28 sec. because of 30 sec. timeout of mod_proxy
|
||||||
count = 14
|
count = 14
|
||||||
while true
|
while true
|
||||||
|
@ -140,8 +145,6 @@ class LongPollingController < ApplicationController
|
||||||
return if !params[:client_id]
|
return if !params[:client_id]
|
||||||
sessions = Session.sessions
|
sessions = Session.sessions
|
||||||
return if !sessions.include?( params[:client_id].to_s )
|
return if !sessions.include?( params[:client_id].to_s )
|
||||||
# Session.update( client_id )
|
|
||||||
# Session.touch( params[:client_id] )
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue