Improved error handling.
This commit is contained in:
parent
09531e7a4d
commit
96c479b40b
|
@ -182,9 +182,18 @@ EventMachine.run {
|
||||||
if local_client_id.to_s != client_id.to_s
|
if local_client_id.to_s != client_id.to_s
|
||||||
|
|
||||||
# broadcast to recipient list
|
# broadcast to recipient list
|
||||||
if data['recipient'] && data['recipient']['user_id']
|
if data['recipient']
|
||||||
|
if data['recipient'].class != Hash
|
||||||
|
log 'error', "recipient attribute isn't a hash '#{ data['recipient'].inspect }'"
|
||||||
|
else
|
||||||
|
if !data['recipient'].has_key?('user_id')
|
||||||
|
log 'error', "need recipient.user_id attribute '#{ data['recipient'].inspect }'"
|
||||||
|
else
|
||||||
|
if data['recipient']['user_id'].class != Array
|
||||||
|
log 'error', "recipient.user_id attribute isn't an array '#{ data['recipient']['user_id'].inspect }'"
|
||||||
|
else
|
||||||
data['recipient']['user_id'].each { |user_id|
|
data['recipient']['user_id'].each { |user_id|
|
||||||
if local_client[:user][:id] == user_id
|
if local_client[:user][:id].to_i == user_id.to_i
|
||||||
log 'notice', "send broadcast to (user_id=#{user_id})", local_client_id
|
log 'notice', "send broadcast to (user_id=#{user_id})", local_client_id
|
||||||
if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
|
if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
|
||||||
@clients[ local_client_id ][:websocket].send( "[#{msg}]" )
|
@clients[ local_client_id ][:websocket].send( "[#{msg}]" )
|
||||||
|
@ -193,6 +202,9 @@ EventMachine.run {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# broadcast every client
|
# broadcast every client
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue