Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log all broadcasted messages; log peername instead of socket_id #12

Merged
merged 3 commits into from
Jan 8, 2022
Merged
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
9 changes: 6 additions & 3 deletions server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function try_send(socket, message)
end

function try_broadcast(room, message)
@info message

for socket in room
try_send(socket, message)
end
Expand All @@ -32,8 +34,9 @@ function start_server(server_host, server_port)

while true
socket = Sockets.accept(server)
socket_id = hash(socket)
@info "socket_id $(socket_id) accepted"

peername = Sockets.getpeername(socket)
@info "socket accepted (peername = $(peername))"

@async begin
try_send(socket, "Enter a nickname")
Expand Down Expand Up @@ -66,7 +69,7 @@ function start_server(server_host, server_port)
close(socket)
end

@info "socket_id $(socket_id) disconnected"
@info "socket disconnected (peername = $(peername))"
end
end

Expand Down