Hi,
This following code streams a file to a process I want to stream audio/mp3 to many users who will hear via html5 audio tag how can it be done via File.stream! ?
defmodule Test do
def say do
receive do
{from, msg} ->
IO.puts "Process #{inspect self} says: #{msg}"
fpath = "./test.txt"
stream_bytes = 128
File.stream!(fpath, [], stream_bytes)
|> Enum.each(fn chunk ->
IO.puts "* streaming #{stream_bytes} bytes...\n #{chunk}"
end)
say
end
end
end
# p = spawn(Test, :say, []);send p, {self, "a message"}
and ‘server.com/service/stream’ will stream mp3 file that I will choose
and all connected users will listen to the stream
a.k.a. radio server
and I want to benchmark how many users can my server handle (without a delay)