websocket_success event
Fired when a websocket is opened with http.websocketAsync.
|
|||
Attempts to start a connection to an echo server and prints when connected. | |||
Code | <nowiki>
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
print("Connected")
break
elseif event == "websocket_failure" and url == wsUrl then
printError("Could not connect")
break
end
end
end
</nowiki>
|
websocket_success Event | |
---|---|
Returns
| |
Source | CC:Tweaked |
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.