Skip to content

Async WebSockets #958

@oliviermilla

Description

@oliviermilla
  • Julia 1.8.2
  • HTTP.jl 1.5.1
  • MbedTLS.jl 1.1.7

Hello everyone,

I am building a package to connect to a websocket service.

Here is my understanding of the WebSockets API, the handler function is what the end user would pass to get callbacks.

function open(handler::Function)
    WebSockets.open(WEBSOCKETS_URL) do ws
        global webSocket[] = ws

        while true
            response = receive(ws)
            handler(JSON3.read(response, Response))
        end
    end
end

function close()
    WebSockets.close(webSocket[])
end

the while true feels really bad I have to say. Isn't there an async API to provide HTTP.WebSockets with callbacks directly?

Love your feedback, just starting out in julia.
Best!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions