websocket_closed event

From ComputerCraft
Jump to: navigation, search
websocket_closed
Event
Returns
  • url : string The URL of the websocket

Source CC:Tweaked

Fired when a websocket connection is closed.

ExampleExampleOpen a websocket and wait for it to close.
Opens a websocket, printing a message when the connection is closed. You can always unplug your network cable if you want to test this!
Code
local wsUrl = "wss://echo.websocket.org/"
local ws = http.websocket(wsUrl)
while true do
    local event, url = os.pullEvent("websocket_closed")
    if url == wsUrl then
        printError("Disconnected!")
        break
    end
end