Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/firehose_server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import JSON
import ..Utils
using ..Utils: ThreadSafe, wait_for

const HOST = Ref("127.0.0.1")
const PORT = Ref(9000)
const HOST::Ref{String} = Ref("127.0.0.1")
const PORT::Ref{Int} = Ref(9000)

const PRINT_EXCEPTIONS = Ref(true)

Expand All @@ -26,7 +26,7 @@ const latest_exceptions = ThreadSafe(CircularBuffer(50))

const message_processors = ThreadSafe(SortedDict{Symbol, Function}())

isactive() = !isnothing(server[])
isactive()::Bool = !isnothing(server[])

function start()
@assert isempty(connections)
Expand Down Expand Up @@ -93,7 +93,7 @@ function stop()
@info "stopped message firehose server on port $(PORT[])"
end

function start_reader_task(sock)
function start_reader_task(sock::TCPSocket)
errormonitor(@async begin
while isactive() && isopen(sock) && isreadable(sock)
s = readline(sock)
Expand Down Expand Up @@ -126,7 +126,7 @@ function start_reader_task(sock)
end)
end

function broadcast(msgs::Vector{String}) # it's better to use broadcast_via_channel
function broadcast(msgs::Vector{String})::Nothing # it's better to use broadcast_via_channel
lock(latest_sent_messages) do lmsgs
for msg in msgs
push!(lmsgs, msg)
Expand Down