That's what I thought too! One of the things I tried was moving the 5.times do loop outside of the begin statement, so that a new SSE is opened and closed once per loop:
5.timesdosse=SSE.new(response.stream)begin# 5.times do character_hash={"uuid":SecureRandom.uuid,"name":name_array.sample,"hp":hp_array.sample,"magic":magic_array.sample}sse.write({character: character_hash})sleep1# endrescueIOError# client disconnectedensuresse.closeendend
And fascinatingly, only ONE character is generated and sent now! Whyyyyy Rails, why won't you let me send multiple SSEs?!
That's interesting. Well, at least it confirms it's waiting for the end of the stream to finish receiving. I wonder if the receiver can be somehow switched back into a state of listening for a new connection at that point?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That's what I thought too! One of the things I tried was moving the
5.times do
loop outside of thebegin
statement, so that a new SSE is opened and closed once per loop:And fascinatingly, only ONE character is generated and sent now! Whyyyyy Rails, why won't you let me send multiple SSEs?!
That's interesting. Well, at least it confirms it's waiting for the end of the stream to finish receiving. I wonder if the receiver can be somehow switched back into a state of listening for a new connection at that point?