Fixed use of last_ping.
This commit is contained in:
parent
94a3797f53
commit
b7ecd9a1eb
2 changed files with 7 additions and 7 deletions
|
@ -35,7 +35,7 @@ returns
|
|||
session_file = "#{path_tmp}/session"
|
||||
|
||||
# collect session data
|
||||
meta[:last_ping] = Time.now.utc.to_i.to_s
|
||||
meta[:last_ping] = Time.now.utc.to_i
|
||||
data = {
|
||||
user: session,
|
||||
meta: meta,
|
||||
|
@ -215,7 +215,7 @@ returns
|
|||
data = get(client_id)
|
||||
return false if !data
|
||||
path = "#{@path}/#{client_id}"
|
||||
data[:meta][:last_ping] = Time.now.utc.to_i.to_s
|
||||
data[:meta][:last_ping] = Time.now.utc.to_i
|
||||
content = data.to_json
|
||||
File.open( path + '/session', 'wb' ) { |file|
|
||||
file.write content
|
||||
|
|
|
@ -96,7 +96,7 @@ EventMachine.run {
|
|||
if !@clients.include? client_id
|
||||
@clients[client_id] = {
|
||||
websocket: ws,
|
||||
last_ping: Time.now.utc.iso8601,
|
||||
last_ping: Time.now.utc.to_i,
|
||||
error_count: 0,
|
||||
}
|
||||
end
|
||||
|
@ -176,7 +176,7 @@ EventMachine.run {
|
|||
# remember ping, send pong back
|
||||
elsif data['action'] == 'ping'
|
||||
Sessions.touch(client_id)
|
||||
@clients[client_id][:last_ping] = Time.now.utc.iso8601
|
||||
@clients[client_id][:last_ping] = Time.now.utc.to_i
|
||||
@clients[client_id][:websocket].send( '[{"action":"pong"}]' )
|
||||
|
||||
# broadcast
|
||||
|
@ -299,7 +299,7 @@ EventMachine.run {
|
|||
# close unused web socket sessions
|
||||
@clients.each { |client_id, client|
|
||||
|
||||
next if ( client[:last_ping] + idle_time_in_sec ) >= Time.now.utc.iso8601
|
||||
next if ( client[:last_ping].to_i + idle_time_in_sec ) >= Time.now.utc.to_i
|
||||
|
||||
log 'notice', 'closing idle websocket connection', client_id
|
||||
|
||||
|
|
Loading…
Reference in a new issue