From bc04072acfa5b12daa19578a309ca6a998268ac4 Mon Sep 17 00:00:00 2001 From: Mandar Chitre Date: Fri, 22 Mar 2024 11:14:00 +0800 Subject: [PATCH] fix(gw): add checks on sock being nothing --- Project.toml | 2 +- src/gw.jl | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 3e5cb99..af570a3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Fjage" uuid = "e0fd600c-be67-11e9-1f90-d366689e4029" authors = ["Mandar Chitre "] -version = "0.5.0" +version = "0.5.1" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/gw.jl b/src/gw.jl index 9c1d265..675ff94 100644 --- a/src/gw.jl +++ b/src/gw.jl @@ -45,6 +45,7 @@ Get the name of the gateway. name(gw::Gateway) = gw.agentID.name function _println(sock, s) + sock === nothing && return @debug ">> $s" try println(sock, s) @@ -79,7 +80,7 @@ _agents_types(gw::Gateway) = [(gw.agentID.name, "Gateway")] _subscriptions(gw::Gateway) = gw.subscriptions _services(gw::Gateway) = String[] _agentsforservice(gw::Gateway, svc) = String[] -_onclose(gw::Gateway) = close(gw.sock[]) +_onclose(gw::Gateway) = gw.sock[] === nothing || close(gw.sock[]) _shutdown(gw::Gateway) = close(gw) _alive(gw::Gateway) = nothing @@ -218,7 +219,7 @@ end function Base.close(gw::Gateway) gw.reconnect[] = false _println(gw.sock[], "{\"alive\": false}") - close(gw.sock[]) + gw.sock[] === nothing || close(gw.sock[]) nothing end