Skip to content

Commit

Permalink
Explain the WS proto selection method
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Jan 21, 2025
1 parent 8f57527 commit 3704316
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/asciinema_web/live_stream_producer_socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,12 @@ defmodule AsciinemaWeb.LiveStreamProducerSocket do
@protos ~w(v1.alis v2.asciicast raw)

defp select_protocol(protos) do
# choose common protos between the client and the server
# using client preferred order
# Choose common protos between the client and the server using client preferred order.
common = protos -- protos -- @protos
# Note the --/2 operator is right associative,
# and this would be more clearly expressed as
# common = protos -- (protos -- @protos)
# but mix.format removes the parenthesis ¯\_(ツ)_/¯

List.first(common)
end
Expand Down

0 comments on commit 3704316

Please sign in to comment.