Skip to content

Commit

Permalink
feat: allow non-string host (e.g. IPv4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mchitre committed Jan 13, 2024
1 parent 32bac40 commit 025bce9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/gw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ struct Gateway
sock::Ref{TCPSocket}
subscriptions::Set{String}
pending::Dict{String,Channel}

msgqueue::Vector
tasks_waiting_for_msg::Vector{Tuple{Task,#=receive_id::=#Int}}
msgqueue_lock::ReentrantLock # Protects both msgqueue and tasks_waiting_for_msg

host::String
port::Int
reconnect::Ref{Bool}
function Gateway(name::String, host::String, port::Int; reconnect=true)
function Gateway(name::String, host, port::Int; reconnect=true)
gw = new(
AgentID(name, false),
Ref(connect(host, port)),
Expand All @@ -28,14 +26,14 @@ struct Gateway
Vector(),
Vector{Tuple{Task,Int}}(),
ReentrantLock(),
host, port, Ref(reconnect)
string(host), port, Ref(reconnect)
)
@async _run(gw)
gw
end
end

Gateway(host::String, port::Int; reconnect=true) = Gateway("julia-gw-" * string(uuid1()), host, port; reconnect=reconnect)
Gateway(host, port::Int; reconnect=true) = Gateway("julia-gw-" * string(uuid1()), host, port; reconnect=reconnect)

Base.show(io::IO, gw::Gateway) = print(io, gw.agentID.name)

Expand Down

0 comments on commit 025bce9

Please sign in to comment.