1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-15 22:34:54 +00:00
CC-Tweaked/doc/events/websocket_failure.md
Jonathan Coates 8a203e7454
Re-license several more files under MPL-2.0
- Several files where @MCJack123 is the exclusive contributor. He has
   signed over all contributions to "any OSI-approved license". Thank
   you!

 - Various the file handle classes: Looking at these again, I don't
   think they contain any of the original code.
2023-03-28 10:28:59 +01:00

864 B

module: [kind=event] websocket_failure see: http.websocketAsync To send an HTTP request.

The @{websocket_failure} event is fired when a WebSocket connection request fails.

This event is normally handled inside @{http.websocket}, but it can still be seen when using @{http.websocketAsync}.

Return Values

  1. @{string}: The event name.
  2. @{string}: The URL of the site requested.
  3. @{string}: An error describing the failure.

Example

Prints an error why the website cannot be contacted:

local myURL = "wss://example.tweaked.cc/not-a-websocket"
http.websocketAsync(myURL)
local event, url, err
repeat
    event, url, err = os.pullEvent("websocket_failure")
until url == myURL
print("The URL " .. url .. " could not be reached: " .. err)