HTTP.jl icon indicating copy to clipboard operation
HTTP.jl copied to clipboard

[RFC] convenience function to check if websocket has incoming messages

Open cpfiffer opened this issue 3 months ago • 0 comments

I need to be able to check if a websocket connection has an incoming message, and I want to open a PR to HTTP.jl to do so. I mostly just want to know the method name you'd suggest, though if there is a more idiomatic/correct way to check whether a message is available I am all ears.

I know that you can access the incoming bytes of a WebSocket with

has_message = !isempty(ws.readbuffer)

Some candidates for this function name:

  • isempty(ws::WebSocket)
  • eof(ws::WebSocket) would be semi-idiomatic here, but the IOBuffer has already been read into readbuffer (I think?)

Perhaps we don't need a convenience function here, but I'd at least like to add something to the documentation string.

cpfiffer avatar Apr 14 '24 22:04 cpfiffer