Corrected with rubocop cop 'Style/Next'.

This commit is contained in:
Thorsten Eckel 2015-05-07 11:04:40 +02:00
parent 7efe34e53b
commit 1ac1cf4184
20 changed files with 360 additions and 322 deletions

View file

@ -218,8 +218,6 @@ Metrics/AbcSize:
Style/RedundantSelf:
Enabled: false
Style/Next:
Enabled: false
Style/CommentIndentation:
Enabled: false
Metrics/CyclomaticComplexity:

View file

@ -233,28 +233,28 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
provider_map.each {|provider, settings|
domains.each {|domain_to_check|
if domain_to_check =~ /#{settings[:domain]}/i
# probe inbound
result = email_probe_inbound( settings[:inbound] )
if result[:result] != 'ok'
render json: result
return # rubocop:disable Lint/NonLocalExitFromIterator
end
next if domain_to_check !~ /#{settings[:domain]}/i
# probe outbound
result = email_probe_outbound( settings[:outbound], params[:email] )
if result[:result] != 'ok'
render json: result
return # rubocop:disable Lint/NonLocalExitFromIterator
end
render json: {
result: 'ok',
setting: settings,
}
# probe inbound
result = email_probe_inbound( settings[:inbound] )
if result[:result] != 'ok'
render json: result
return # rubocop:disable Lint/NonLocalExitFromIterator
end
# probe outbound
result = email_probe_outbound( settings[:outbound], params[:email] )
if result[:result] != 'ok'
render json: result
return # rubocop:disable Lint/NonLocalExitFromIterator
end
render json: {
result: 'ok',
setting: settings,
}
return # rubocop:disable Lint/NonLocalExitFromIterator
}
}
@ -394,11 +394,12 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
logger.info "INBOUND PROBE: #{config.inspect}"
result = email_probe_inbound( config )
logger.info "INBOUND RESULT: #{result.inspect}"
if result[:result] == 'ok'
success = true
settings[:inbound] = config
break
end
next if result[:result] != 'ok'
success = true
settings[:inbound] = config
break
}
if !success
@ -543,11 +544,12 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
logger.info "OUTBOUND PROBE: #{config.inspect}"
result = email_probe_outbound( config, params[:email] )
logger.info "OUTBOUND RESULT: #{result.inspect}"
if result[:result] == 'ok'
success = true
settings[:outbound] = config
break
end
next if result[:result] != 'ok'
success = true
settings[:outbound] = config
break
}
if !success
@ -635,66 +637,66 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
return # rubocop:disable Lint/NonLocalExitFromIterator
end
if found && found == 'verify ok'
next if !found
next if found != 'verify ok'
# remember address
address = EmailAddress.where( email: params[:meta][:email] ).first
if !address
address = EmailAddress.first
end
if address
address.update_attributes(
realname: params[:meta][:realname],
email: params[:meta][:email],
active: 1,
updated_by_id: 1,
created_by_id: 1,
)
else
EmailAddress.create(
realname: params[:meta][:realname],
email: params[:meta][:email],
active: 1,
updated_by_id: 1,
created_by_id: 1,
)
end
# store mailbox
Channel.create(
area: 'Email::Inbound',
adapter: params[:inbound][:adapter],
options: params[:inbound][:options],
group_id: 1,
# remember address
address = EmailAddress.where( email: params[:meta][:email] ).first
if !address
address = EmailAddress.first
end
if address
address.update_attributes(
realname: params[:meta][:realname],
email: params[:meta][:email],
active: 1,
updated_by_id: 1,
created_by_id: 1,
)
else
EmailAddress.create(
realname: params[:meta][:realname],
email: params[:meta][:email],
active: 1,
updated_by_id: 1,
created_by_id: 1,
)
# save settings
if params[:outbound][:adapter] =~ /^smtp$/i
smtp = Channel.where( adapter: 'SMTP', area: 'Email::Outbound' ).first
smtp.options = params[:outbound][:options]
smtp.active = true
smtp.save!
sendmail = Channel.where( adapter: 'Sendmail' ).first
sendmail.active = false
sendmail.save!
else
sendmail = Channel.where( adapter: 'Sendmail', area: 'Email::Outbound' ).first
sendmail.options = {}
sendmail.active = true
sendmail.save!
smtp = Channel.where( adapter: 'SMTP' ).first
smtp.active = false
smtp.save
end
render json: {
result: 'ok',
}
return # rubocop:disable Lint/NonLocalExitFromIterator
end
# store mailbox
Channel.create(
area: 'Email::Inbound',
adapter: params[:inbound][:adapter],
options: params[:inbound][:options],
group_id: 1,
active: 1,
updated_by_id: 1,
created_by_id: 1,
)
# save settings
if params[:outbound][:adapter] =~ /^smtp$/i
smtp = Channel.where( adapter: 'SMTP', area: 'Email::Outbound' ).first
smtp.options = params[:outbound][:options]
smtp.active = true
smtp.save!
sendmail = Channel.where( adapter: 'Sendmail' ).first
sendmail.active = false
sendmail.save!
else
sendmail = Channel.where( adapter: 'Sendmail', area: 'Email::Outbound' ).first
sendmail.options = {}
sendmail.active = true
sendmail.save!
smtp = Channel.where( adapter: 'SMTP' ).first
smtp.active = false
smtp.save
end
render json: {
result: 'ok',
}
return # rubocop:disable Lint/NonLocalExitFromIterator
}
# check delivery for 30 sek.
@ -768,14 +770,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
'Recipient address rejected' => true,
}
white_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i
result = {
result: 'ok',
settings: params,
notice: e.message,
}
return result
end
next if e.message !~ /#{Regexp.escape(key)}/i
result = {
result: 'ok',
settings: params,
notice: e.message,
}
return result
}
end
message_human = ''

View file

@ -107,17 +107,18 @@ returns
# set relations
self.class.reflect_on_all_associations.map { |assoc|
real_key = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
if params.key?( real_key.to_sym )
list_of_items = params[ real_key.to_sym ]
if params[ real_key.to_sym ].class != Array
list_of_items = [ params[ real_key.to_sym ] ]
end
list = []
list_of_items.each {|item|
list.push( assoc.klass.find(item) )
}
self.send( assoc.name.to_s + '=', list )
next if !params.key?( real_key.to_sym )
list_of_items = params[ real_key.to_sym ]
if params[ real_key.to_sym ].class != Array
list_of_items = [ params[ real_key.to_sym ] ]
end
list = []
list_of_items.each {|item|
list.push( assoc.klass.find(item) )
}
self.send( assoc.name.to_s + '=', list )
}
end

View file

@ -66,35 +66,37 @@ class Channel::EmailParser
# set all headers
mail.header.fields.each { |field|
if field.name
# full line, encode, ready for storage
data[field.name.to_s.downcase.to_sym] = Encode.conv( 'utf8', field.to_s )
next if !field.name
# if we need to access the lines by objects later again
data[ "raw-#{field.name.downcase}".to_sym ] = field
end
# full line, encode, ready for storage
data[field.name.to_s.downcase.to_sym] = Encode.conv( 'utf8', field.to_s )
# if we need to access the lines by objects later again
data[ "raw-#{field.name.downcase}".to_sym ] = field
}
# get sender
from = nil
['from', 'reply-to', 'return-path'].each { |item|
if !from
if mail[ item.to_sym ]
from = mail[ item.to_sym ].value
end
end
next if !mail[ item.to_sym ]
from = mail[ item.to_sym ].value
break if from
}
# set x-any-recipient
data['x-any-recipient'.to_sym] = ''
['to', 'cc', 'delivered-to', 'x-original-to', 'envelope-to'].each { |item|
if mail[item.to_sym]
if data['x-any-recipient'.to_sym] != ''
data['x-any-recipient'.to_sym] += ', '
end
data['x-any-recipient'.to_sym] += mail[item.to_sym].to_s
next if !mail[item.to_sym]
if data['x-any-recipient'.to_sym] != ''
data['x-any-recipient'.to_sym] += ', '
end
data['x-any-recipient'.to_sym] += mail[item.to_sym].to_s
}
# set extra headers
@ -374,16 +376,18 @@ class Channel::EmailParser
# create to and cc user
['raw-to', 'raw-cc'].each { |item|
if mail[item.to_sym] && mail[item.to_sym].tree
items = mail[item.to_sym].tree
items.addresses.each {|item|
user_create(
firstname: item.display_name,
lastname: '',
email: item.address,
)
}
end
next if !mail[item.to_sym]
next if !mail[item.to_sym].tree
items = mail[item.to_sym].tree
items.addresses.each {|item|
user_create(
firstname: item.display_name,
lastname: '',
email: item.address,
)
}
}
# set current user
@ -541,18 +545,19 @@ class Channel::EmailParser
if mail[ header.to_sym ]
Rails.logger.info "header #{header} found #{mail[ header.to_sym ]}"
item_object.class.reflect_on_all_associations.map { |assoc|
if assoc.name.to_s == key_short
Rails.logger.info "ASSOC found #{assoc.class_name} lookup #{mail[ header.to_sym ]}"
item = assoc.class_name.constantize
if item.respond_to?(:name)
if item.lookup( name: mail[ header.to_sym ] )
item_object[key] = item.lookup( name: mail[ header.to_sym ] ).id
end
elsif item.respond_to?(:login)
if item.lookup( login: mail[ header.to_sym ] )
item_object[key] = item.lookup( login: mail[ header.to_sym ] ).id
end
next if assoc.name.to_s != key_short
Rails.logger.info "ASSOC found #{assoc.class_name} lookup #{mail[ header.to_sym ]}"
item = assoc.class_name.constantize
if item.respond_to?(:name)
if item.lookup( name: mail[ header.to_sym ] )
item_object[key] = item.lookup( name: mail[ header.to_sym ] ).id
end
elsif item.respond_to?(:login)
if item.lookup( login: mail[ header.to_sym ] )
item_object[key] = item.lookup( login: mail[ header.to_sym ] ).id
end
end
}

View file

@ -10,9 +10,9 @@ module Channel::Filter::Database
filters.each {|filter|
Rails.logger.info " proccess filter #{filter.name} ..."
match = true
loop = false
looped = false
filter[:match].each {|key, value|
loop = true
looped = true
begin
scan = []
if mail
@ -31,12 +31,14 @@ module Channel::Filter::Database
Rails.logger.error e.inspect
end
}
if loop && match
filter[:perform].each {|key, value|
Rails.logger.info " perform '#{ key.downcase }' = '#{value}'"
mail[ key.downcase.to_sym ] = value
}
end
next if !looped
next if !match
filter[:perform].each {|key, value|
Rails.logger.info " perform '#{ key.downcase }' = '#{value}'"
mail[ key.downcase.to_sym ] = value
}
}
end

View file

@ -37,12 +37,14 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
# add history record
recipient_list = ''
[:to, :cc].each { |key|
if record[key] && record[key] != ''
if recipient_list != ''
recipient_list += ','
end
recipient_list += record[key]
next if !record[key]
next if record[key] == ''
if recipient_list != ''
recipient_list += ','
end
recipient_list += record[key]
}
return if recipient_list == ''

View file

@ -313,14 +313,15 @@ class Package < ApplicationModel
def self.reload_classes
%w(app lib).each {|dir|
Dir.glob( Rails.root.join( dir + '/**/*') ).each {|entry|
if entry =~ /\.rb$/
begin
load entry
rescue => e
logger.error "TRIED TO RELOAD '#{entry}'"
logger.error 'ERROR: ' + e.inspect
logger.error 'Traceback: ' + e.backtrace.inspect
end
next if entry !~ /\.rb$/
begin
load entry
rescue => e
logger.error "TRIED TO RELOAD '#{entry}'"
logger.error 'ERROR: ' + e.inspect
logger.error 'Traceback: ' + e.backtrace.inspect
end
}
}
@ -396,11 +397,11 @@ class Package < ApplicationModel
(1..position).each {|count|
tmp_path = tmp_path + '/' + directories[count].to_s
}
if tmp_path != ''
if !File.exist?(tmp_path)
Dir.mkdir( tmp_path, 0755)
end
end
next if tmp_path == ''
next if File.exist?(tmp_path)
Dir.mkdir(tmp_path, 0755)
}
# install file

View file

@ -46,12 +46,13 @@ class Store
content = item.content
sha = Digest::SHA256.hexdigest( content )
logger.info "CHECK: Store::File.find(#{item.id}) "
if sha != item.sha
success = false
logger.error "DIFF: sha diff of Store::File.find(#{item.id}) "
if fix_it
item.update_attribute( :sha, sha )
end
next if sha == item.sha
success = false
logger.error "DIFF: sha diff of Store::File.find(#{item.id}) "
if fix_it
item.update_attribute( :sha, sha )
end
}
success

View file

@ -189,15 +189,16 @@ returns
[ 'tickets.group_id', 'group_id' ]
]
map.each {|item|
if sla.condition[ item[0] ]
if sla.condition[ item[0] ].class == String
sla.condition[ item[0] ] = [ sla.condition[ item[0] ] ]
end
if sla.condition[ item[0] ].include?( self[ item[1] ].to_s )
hit = true
else
hit = false
end
next if !sla.condition[ item[0] ]
if sla.condition[ item[0] ].class == String
sla.condition[ item[0] ] = [ sla.condition[ item[0] ] ]
end
if sla.condition[ item[0] ].include?( self[ item[1] ].to_s )
hit = true
else
hit = false
end
}
if hit

View file

@ -73,12 +73,17 @@ returns
# replace e.g. 'current_user.id' with current_user.id
overview.condition.each { |item, value|
if value && value.class.to_s == 'String'
parts = value.split( '.', 2 )
if parts[0] && parts[1] && parts[0] == 'current_user'
overview.condition[item] = data[:current_user][parts[1].to_sym]
end
end
next if !value
next if value.class.to_s != 'String'
parts = value.split( '.', 2 )
next if !parts[0]
next if !parts[1]
next if parts[0] != 'current_user'
overview.condition[item] = data[:current_user][parts[1].to_sym]
}
}

View file

@ -64,12 +64,13 @@ returns
end
state_types.each {|type|
state_type = Ticket::StateType.where( name: type ).first
if state_type
state_type.states.each {|state|
assets = state.assets(assets)
state_ids.push state.id
}
end
next if !state_type
state_type.states.each {|state|
assets = state.assets(assets)
state_ids.push state.id
}
}
filter[:state_id] = state_ids

View file

@ -83,21 +83,22 @@ returns
end
# check file size
if attachment.content && attachment.content.size / 1024 <= attachment_max_size_in_mb * 1024
next if !attachment.content
next if attachment.content.size / 1024 > attachment_max_size_in_mb * 1024
# check ignored files
if attachment.filename
filename_extention = attachment.filename.downcase
filename_extention.gsub!(/^.*(\..+?)$/, '\\1')
if !attachments_ignore.include?( filename_extention.downcase )
data = {
'_name' => attachment.filename,
'_content' => Base64.encode64( attachment.content )
}
article_attributes['attachments'].push data
end
end
end
# check ignored files
next if !attachment.filename
filename_extention = attachment.filename.downcase
filename_extention.gsub!(/^.*(\..+?)$/, '\\1')
next if attachments_ignore.include?( filename_extention.downcase )
data = {
'_name' => attachment.filename,
'_content' => Base64.encode64( attachment.content )
}
article_attributes['attachments'].push data
}
attributes['articles'].push article_attributes
}

View file

@ -45,16 +45,15 @@ returns
user_auth = backend.check( username, password, config_item, user )
# auth ok
if user_auth
# auth not ok
next if !user_auth
Rails.logger.info "Authentication against #{config_item[:adapter]} for user #{user_auth.login} ok."
Rails.logger.info "Authentication against #{config_item[:adapter]} for user #{user_auth.login} ok."
# remember last login date
user_auth.update_last_login
# remember last login date
user_auth.update_last_login
return user_auth
end
return user_auth
}
nil
end

View file

@ -522,18 +522,20 @@ module Import::OTRS
created_by_id: history['CreateBy']
)
end
if history['ArticleID'] && history['ArticleID'] != 0
History.add(
id: history['HistoryID'],
o_id: history['ArticleID'],
history_type: 'created',
history_object: 'Ticket::Article',
related_o_id: history['TicketID'],
related_history_object: 'Ticket',
created_at: history['CreateTime'],
created_by_id: history['CreateBy']
)
end
next if !history['ArticleID']
next if history['ArticleID'] == 0
History.add(
id: history['HistoryID'],
o_id: history['ArticleID'],
history_type: 'created',
history_object: 'Ticket::Article',
related_o_id: history['TicketID'],
related_history_object: 'Ticket',
created_at: history['CreateTime'],
created_by_id: history['CreateBy']
)
}
end
}

View file

@ -747,18 +747,20 @@ module Import::OTRS2
created_by_id: history['CreateBy']
)
end
if history['ArticleID'] && history['ArticleID'] != 0
History.add(
id: history['HistoryID'],
o_id: history['ArticleID'],
history_type: 'created',
history_object: 'Ticket::Article',
related_o_id: history['TicketID'],
related_history_object: 'Ticket',
created_at: history['CreateTime'],
created_by_id: history['CreateBy']
)
end
next if !history['ArticleID']
next if history['ArticleID'] == 0
History.add(
id: history['HistoryID'],
o_id: history['ArticleID'],
history_type: 'created',
history_object: 'Ticket::Article',
related_o_id: history['TicketID'],
related_history_object: 'Ticket',
created_at: history['CreateTime'],
created_by_id: history['CreateBy']
)
}
}
end
@ -974,11 +976,12 @@ module Import::OTRS2
# lookup by groups
user['GroupIDs'].each {|group_id, permissions|
queues.each {|queue_lookup|
if queue_lookup['GroupID'] == group_id
if permissions && permissions.include?('rw')
queue_ids.push queue_lookup['QueueID']
end
end
next if queue_lookup['GroupID'] != group_id
next if !permissions
next if !permissions.include?('rw')
queue_ids.push queue_lookup['QueueID']
}
}
@ -996,14 +999,18 @@ module Import::OTRS2
role_ids = []
user['GroupIDs'].each {|group_id, permissions|
groups.each {|group_lookup|
if group_id == group_lookup['ID']
if group_lookup['Name'] == 'admin' && permissions && permissions.include?('rw')
roles.push 'Admin'
end
if group_lookup['Name'] =~ /^(stats|report)/ && permissions && ( permissions.include?('ro') || permissions.include?('rw') )
roles.push 'Report'
end
next if group_id != group_lookup['ID']
next if permissions
if group_lookup['Name'] == 'admin' && permissions.include?('rw')
roles.push 'Admin'
end
next if group_lookup['Name'] !~ /^(stats|report)/
next if !( permissions.include?('ro') || permissions.include?('rw') )
roles.push 'Report'
}
}
roles.each {|role|

View file

@ -63,11 +63,12 @@ module NotificationFactory
object_refs = object_refs.send( method.to_sym )
# add body quote
if object_name == 'article' && method == 'body'
if data[:objects][:article].content_type == 'text/html'
object_refs = object_refs.html2text.chomp
end
end
next if object_name != 'article'
next if method != 'body'
next if data[:objects][:article].content_type != 'text/html'
object_refs = object_refs.html2text.chomp
}
if !value
placeholder = object_refs

View file

@ -470,14 +470,16 @@ returns
# spool to recipient list
if message_parsed['recipient'] && message_parsed['recipient']['user_id']
message_parsed['recipient']['user_id'].each { |user_id|
if current_user_id == user_id
item = {
type: 'direct',
message: message_parsed,
}
data.push item
end
next if current_user_id != user_id
item = {
type: 'direct',
message: message_parsed,
}
data.push item
}
# spool to every client
@ -521,16 +523,16 @@ returns
next if !user
# start client thread
if !@@client_threads[client_id]
@@client_threads[client_id] = true
@@client_threads[client_id] = Thread.new {
thread_client(client_id)
@@client_threads[client_id] = nil
Rails.logger.debug "close client (#{client_id}) thread"
ActiveRecord::Base.connection.close
}
sleep 0.5
end
next if @@client_threads[client_id]
@@client_threads[client_id] = true
@@client_threads[client_id] = Thread.new {
thread_client(client_id)
@@client_threads[client_id] = nil
Rails.logger.debug "close client (#{client_id}) thread"
ActiveRecord::Base.connection.close
}
sleep 0.5
}
# system settings

View file

@ -56,16 +56,15 @@ returns
user_auth = backend.check( params, config_item )
# auth ok
if user_auth
# auth not ok
next if !user_auth
Rails.logger.info "Authentication against #{config_item[:adapter]} for user #{user.login} ok."
Rails.logger.info "Authentication against #{config_item[:adapter]} for user #{user.login} ok."
# remember last login date
user_auth.update_last_login
# remember last login date
user_auth.update_last_login
return user_auth
end
return user_auth
}
nil
end

View file

@ -35,17 +35,21 @@ put working hours matrix and timezone in function, returns UTC working hours mat
working_hours = {}
[:Mon, :Tue, :Wed, :Thu, :Fri, :Sat, :Sun].each {|day|
working_hours[day] = []
if config[day.to_s] == true || config[day.to_s] == day.to_s
config_ok = true
(0..23).each {|hour|
time = Time.parse("1977-10-27 #{hour}:00:00")
if time >= beginning_of_workday && time <= end_of_workday
working_hours[day].push true
else
working_hours[day].push nil
end
}
next if !config[day.to_s]
if config[day.to_s] != true && config[day.to_s] != day.to_s
next
end
config_ok = true
(0..23).each {|hour|
time = Time.parse("1977-10-27 #{hour}:00:00")
if time >= beginning_of_workday && time <= end_of_workday
working_hours[day].push true
else
working_hours[day].push nil
end
}
}
if !config_ok
@ -67,23 +71,24 @@ put working hours matrix and timezone in function, returns UTC working hours mat
}
(1..hours_to_shift).each {|count|
working_hours.each {|day, value|
if working_hours[day]
to_move = working_hours[day].shift
if day == :Mon
move_items[:Tue].push to_move
elsif day == :Tue
move_items[:Wed].push to_move
elsif day == :Wed
move_items[:Thu].push to_move
elsif day == :Thu
move_items[:Fri].push to_move
elsif day == :Fri
move_items[:Sat].push to_move
elsif day == :Sat
move_items[:Sun].push to_move
elsif day == :Sun
move_items[:Mon].push to_move
end
next if !working_hours[day]
to_move = working_hours[day].shift
if day == :Mon
move_items[:Tue].push to_move
elsif day == :Tue
move_items[:Wed].push to_move
elsif day == :Wed
move_items[:Thu].push to_move
elsif day == :Thu
move_items[:Fri].push to_move
elsif day == :Fri
move_items[:Sat].push to_move
elsif day == :Sat
move_items[:Sun].push to_move
elsif day == :Sun
move_items[:Mon].push to_move
end
}
}

View file

@ -198,13 +198,14 @@ EventMachine.run {
log 'error', "recipient.user_id attribute isn't an array '#{ data['recipient']['user_id'].inspect }'"
else
data['recipient']['user_id'].each { |user_id|
if local_client[:user]['id'].to_i == user_id.to_i
log 'notice', "send broadcast from (#{client_id}) to (user_id=#{user_id})", local_client_id
if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
@clients[ local_client_id ][:websocket].send( "[#{msg}]" )
else
Sessions.send( local_client_id, data )
end
next if local_client[:user]['id'].to_i != user_id.to_i
log 'notice', "send broadcast from (#{client_id}) to (user_id=#{user_id})", local_client_id
if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
@clients[ local_client_id ][:websocket].send( "[#{msg}]" )
else
Sessions.send( local_client_id, data )
end
}
end
@ -296,19 +297,20 @@ EventMachine.run {
# close unused web socket sessions
@clients.each { |client_id, client|
if ( client[:last_ping] + idle_time_in_sec ) < Time.now
log 'notice', 'closing idle websocket connection', client_id
# remember to not use this connection anymore
client[:disconnect] = true
next if ( client[:last_ping] + idle_time_in_sec ) >= Time.now
# try to close regular
client[:websocket].close_websocket
log 'notice', 'closing idle websocket connection', client_id
# delete session from client list
sleep 0.3
@clients.delete(client_id)
end
# remember to not use this connection anymore
client[:disconnect] = true
# try to close regular
client[:websocket].close_websocket
# delete session from client list
sleep 0.3
@clients.delete(client_id)
}
# close unused ajax long polling sessions