Fired when a websocket is opened with http.websocketAsync.
|ExampleAttempt to open a websocket and wait for it to connect.|
|Attempts to start a connection to an echo server and prints when connected.
local wsUrl = "wss://echo.websocket.org"
local ok, err = http.websocketAsync(wsUrl)
if ok then
while true do
-- Wait for a websocket_success or websocket_failure event
-- matching the desired URL
local event, url, res = os.pullEvent(url)
if event == "websocket_success" and url == wsUrl then
elseif event == "websocket_failure" and url == wsUrl then
printError("Could not connect")