diff --git a/Project.toml b/Project.toml index 1cb69bd68..027457b94 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Genie" uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e" authors = ["Adrian Salceanu "] -version = "5.19.0" +version = "5.19.1" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" diff --git a/src/WebChannels.jl b/src/WebChannels.jl index 42ec4f878..cee940d13 100755 --- a/src/WebChannels.jl +++ b/src/WebChannels.jl @@ -221,25 +221,29 @@ function broadcast(channels::Union{ChannelName,Vector{ChannelName}}, isempty(SUBSCRIPTIONS) && return false - for channel in channels - haskey(SUBSCRIPTIONS, channel) || throw(ChannelNotFoundException(channel)) - - for client in SUBSCRIPTIONS[channel] - except !== nothing && client == id(except) && continue - HTTP.WebSockets.isclosed(CLIENTS[client].client) && continue - - try - payload !== nothing ? - message(client, ChannelMessage(channel, client, msg, payload) |> Renderer.Json.JSONParser.json) : - message(client, msg) - catch ex - if isa(ex, Base.IOError) - unsubscribe_disconnected_clients(channel) - else - @error ex + try + for channel in channels + haskey(SUBSCRIPTIONS, channel) || throw(ChannelNotFoundException(channel)) + + for client in SUBSCRIPTIONS[channel] + except !== nothing && client == id(except) && continue + HTTP.WebSockets.isclosed(CLIENTS[client].client) && continue + + try + payload !== nothing ? + message(client, ChannelMessage(channel, client, msg, payload) |> Renderer.Json.JSONParser.json) : + message(client, msg) + catch ex + if isa(ex, Base.IOError) + unsubscribe_disconnected_clients(channel) + else + @error ex + end end end end + catch ex + @error ex end true @@ -253,8 +257,13 @@ function broadcast(msg::String; channels::Union{Union{ChannelName,Vector{ChannelName}},Nothing} = nothing, payload::Union{Dict,Nothing} = nothing, except::Union{HTTP.WebSockets.WebSocket,Nothing,UInt} = nothing) :: Bool - channels === nothing && (channels = collect(keys(SUBSCRIPTIONS))) - broadcast(channels, msg, payload; except = except) + try + channels === nothing && (channels = collect(keys(SUBSCRIPTIONS))) + broadcast(channels, msg, payload; except = except) + catch ex + @error ex + false + end end