websocket_closed event

websocket_closed
Event
Returns
  • url : string The URL of the websocket

Source CC:Tweaked

Fired when a websocket connection is closed.

ExampleOpen 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
<nowiki>
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
    </nowiki>
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.