mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-15 12:40:30 +00:00
895bc7721a
This adds SPDX license headers to all source code files, following the REUSE[1] specification. This does not include any asset files (such as generated JSON files, or textures). While REUSE does support doing so with ".license" files, for now we define these licences using the .reuse/dep5 file. [1]: https://reuse.software/
32 lines
872 B
Markdown
32 lines
872 B
Markdown
---
|
|
module: [kind=event] websocket_failure
|
|
see: http.websocketAsync To send an HTTP request.
|
|
---
|
|
|
|
<!--
|
|
SPDX-FileCopyrightText: 2021 The CC: Tweaked Developers
|
|
|
|
SPDX-License-Identifier: LicenseRef-CCPL
|
|
-->
|
|
|
|
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:
|
|
```lua
|
|
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)
|
|
```
|