diff --git a/doc/events/alarm.md b/doc/events/alarm.md deleted file mode 100644 index db7f04845..000000000 --- a/doc/events/alarm.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -module: [kind=event] alarm -see: os.setAlarm To start an alarm. ---- - -The @{timer} event is fired when an alarm started with @{os.setAlarm} completes. - -## Return Values -1. @{string}: The event name. -2. @{number}: The ID of the alarm that finished. - -## Example -Starts a timer and then prints its ID: -```lua -local alarmID = os.setAlarm(os.time() + 0.05) -local event, id -repeat - event, id = os.pullEvent("alarm") -until id == alarmID -print("Alarm with ID " .. id .. " was fired") -``` diff --git a/doc/events/char.md b/doc/events/char.md deleted file mode 100644 index 473313702..000000000 --- a/doc/events/char.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -module: [kind=event] char -see: key To listen to any key press. ---- - -The @{char} event is fired when a character is _typed_ on the keyboard. - -The @{char} event is different to a key press. Sometimes multiple key presses may result in one character being -typed (for instance, on some European keyboards). Similarly, some keys (e.g. Ctrl) do not have any -corresponding character. The @{key} should be used if you want to listen to key presses themselves. - -## Return values -1. @{string}: The event name. -2. @{string}: The string representing the character that was pressed. - - -## Example -Prints each character the user presses: -```lua -while true do - local event, character = os.pullEvent("char") - print(character .. " was pressed.") -end -``` diff --git a/doc/events/computer_command.md b/doc/events/computer_command.md deleted file mode 100644 index 245252399..000000000 --- a/doc/events/computer_command.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -module: [kind=event] computer_command ---- - -The @{computer_command} event is fired when the `/computercraft queue` command is run for the current computer. - -## Return Values -1. @{string}: The event name. -... @{string}: The arguments passed to the command. - -## Example -Prints the contents of messages sent: -```lua -while true do - local event = {os.pullEvent("computer_command")} - print("Received message:", table.unpack(event, 2)) -end -``` diff --git a/doc/events/disk.md b/doc/events/disk.md deleted file mode 100644 index 2946d70c4..000000000 --- a/doc/events/disk.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -module: [kind=event] disk -see: disk_eject For the event sent when a disk is removed. ---- - -The @{disk} event is fired when a disk is inserted into an adjacent or networked disk drive. - -## Return Values -1. @{string}: The event name. -2. @{string}: The side of the disk drive that had a disk inserted. - -## Example -Prints a message when a disk is inserted: -```lua -while true do - local event, side = os.pullEvent("disk") - print("Inserted a disk on side " .. side) -end -``` diff --git a/doc/events/disk_eject.md b/doc/events/disk_eject.md deleted file mode 100644 index 71c3ede0a..000000000 --- a/doc/events/disk_eject.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -module: [kind=event] disk_eject -see: disk For the event sent when a disk is inserted. ---- - -The @{disk_eject} event is fired when a disk is removed from an adjacent or networked disk drive. - -## Return Values -1. @{string}: The event name. -2. @{string}: The side of the disk drive that had a disk removed. - -## Example -Prints a message when a disk is removed: -```lua -while true do - local event, side = os.pullEvent("disk_eject") - print("Removed a disk on side " .. side) -end -``` diff --git a/doc/events/http_check.md b/doc/events/http_check.md deleted file mode 100644 index 9af5ea7ca..000000000 --- a/doc/events/http_check.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -module: [kind=event] http_check -see: http.checkURLAsync To check a URL asynchronously. ---- - -The @{http_check} event is fired when a URL check finishes. - -This event is normally handled inside @{http.checkURL}, but it can still be seen when using @{http.checkURLAsync}. - -## Return Values -1. @{string}: The event name. -2. @{string}: The URL requested to be checked. -3. @{boolean}: Whether the check succeeded. -4. @{string|nil}: If the check failed, a reason explaining why the check failed. diff --git a/doc/events/http_failure.md b/doc/events/http_failure.md deleted file mode 100644 index dc10b40d7..000000000 --- a/doc/events/http_failure.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -module: [kind=event] http_failure -see: http.request To send an HTTP request. ---- - -The @{http_failure} event is fired when an HTTP request fails. - -This event is normally handled inside @{http.get} and @{http.post}, but it can still be seen when using @{http.request}. - -## Return Values -1. @{string}: The event name. -2. @{string}: The URL of the site requested. -3. @{string}: An error describing the failure. -4. @{http.Response|nil}: A response handle if the connection succeeded, but the server's response indicated failure. - -## Example -Prints an error why the website cannot be contacted: -```lua -local myURL = "https://does.not.exist.tweaked.cc" -http.request(myURL) -local event, url, err -repeat - event, url, err = os.pullEvent("http_failure") -until url == myURL -print("The URL " .. url .. " could not be reached: " .. err) -``` - -Prints the contents of a webpage that does not exist: -```lua -local myURL = "https://tweaked.cc/this/does/not/exist" -http.request(myURL) -local event, url, err, handle -repeat - event, url, err, handle = os.pullEvent("http_failure") -until url == myURL -print("The URL " .. url .. " could not be reached: " .. err) -print(handle.getResponseCode()) -handle.close() -``` diff --git a/doc/events/http_success.md b/doc/events/http_success.md deleted file mode 100644 index 3700b9211..000000000 --- a/doc/events/http_success.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -module: [kind=event] http_success -see: http.request To make an HTTP request. ---- - -The @{http_success} event is fired when an HTTP request returns successfully. - -This event is normally handled inside @{http.get} and @{http.post}, but it can still be seen when using @{http.request}. - -## Return Values -1. @{string}: The event name. -2. @{string}: The URL of the site requested. -3. @{http.Response}: The handle for the response text. - -## Example -Prints the content of a website (this may fail if the request fails): -```lua -local myURL = "https://tweaked.cc/" -http.request(myURL) -local event, url, handle -repeat - event, url, handle = os.pullEvent("http_success") -until url == myURL -print("Contents of " .. url .. ":") -print(handle.readAll()) -handle.close() -``` diff --git a/doc/events/key.md b/doc/events/key.md deleted file mode 100644 index 59598d8dd..000000000 --- a/doc/events/key.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -module: [kind=event] key ---- - -This event is fired when any key is pressed while the terminal is focused. - -This event returns a numerical "key code" (for instance, F1 is 290). This value may vary between versions and -so it is recommended to use the constants in the @{keys} API rather than hard coding numeric values. - -If the button pressed represented a printable character, then the @{key} event will be followed immediately by a @{char} -event. If you are consuming text input, use a @{char} event instead! - -## Return values -1. @{string}: The event name. -2. @{number}: The numerical key value of the key pressed. -3. @{boolean}: Whether the key event was generated while holding the key (@{true}), rather than pressing it the first time (@{false}). - -## Example -Prints each key when the user presses it, and if the key is being held. - -```lua -while true do - local event, key, is_held = os.pullEvent("key") - print(("%s held=%b"):format(keys.getName(key), is_held)) -end -``` diff --git a/doc/events/key_up.md b/doc/events/key_up.md deleted file mode 100644 index e957cae6b..000000000 --- a/doc/events/key_up.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -module: [kind=event] key_up -see: keys For a lookup table of the given keys. ---- - -Fired whenever a key is released (or the terminal is closed while a key was being pressed). - -This event returns a numerical "key code" (for instance, F1 is 290). This value may vary between versions and -so it is recommended to use the constants in the @{keys} API rather than hard coding numeric values. - -## Return values -1. @{string}: The event name. -2. @{number}: The numerical key value of the key pressed. - -## Example -Prints each key released on the keyboard whenever a @{key_up} event is fired. - -```lua -while true do - local event, key = os.pullEvent("key_up") - local name = keys.getName(key) or "unknown key" - print(name .. " was released.") -end -``` diff --git a/doc/events/modem_message.md b/doc/events/modem_message.md deleted file mode 100644 index ec619f3d4..000000000 --- a/doc/events/modem_message.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -module: [kind=event] modem_message ---- - -The @{modem_message} event is fired when a message is received on an open channel on any modem. - -## Return Values -1. @{string}: The event name. -2. @{string}: The side of the modem that received the message. -3. @{number}: The channel that the message was sent on. -4. @{number}: The reply channel set by the sender. -5. @{any}: The message as sent by the sender. -6. @{number}: The distance between the sender and the receiver, in blocks (decimal). - -## Example -Prints a message when one is sent: -```lua -while true do - local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") - print(("Message received on side %s on channel %d (reply to %d) from %f blocks away with message %s"):format(side, channel, replyChannel, distance, tostring(message))) -end -``` diff --git a/doc/events/monitor_resize.md b/doc/events/monitor_resize.md deleted file mode 100644 index 03de804e7..000000000 --- a/doc/events/monitor_resize.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -module: [kind=event] monitor_resize ---- - -The @{monitor_resize} event is fired when an adjacent or networked monitor's size is changed. - -## Return Values -1. @{string}: The event name. -2. @{string}: The side or network ID of the monitor that resized. - -## Example -Prints a message when a monitor is resized: -```lua -while true do - local event, side = os.pullEvent("monitor_resize") - print("The monitor on side " .. side .. " was resized.") -end -``` diff --git a/doc/events/monitor_touch.md b/doc/events/monitor_touch.md deleted file mode 100644 index 0f27a9cc1..000000000 --- a/doc/events/monitor_touch.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -module: [kind=event] monitor_touch ---- - -The @{monitor_touch} event is fired when an adjacent or networked Advanced Monitor is right-clicked. - -## Return Values -1. @{string}: The event name. -2. @{string}: The side or network ID of the monitor that was touched. -3. @{number}: The X coordinate of the touch, in characters. -4. @{number}: The Y coordinate of the touch, in characters. - -## Example -Prints a message when a monitor is touched: -```lua -while true do - local event, side, x, y = os.pullEvent("monitor_touch") - print("The monitor on side " .. side .. " was touched at (" .. x .. ", " .. y .. ")") -end -``` diff --git a/doc/events/mouse_click.md b/doc/events/mouse_click.md deleted file mode 100644 index 83d371260..000000000 --- a/doc/events/mouse_click.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -module: [kind=event] mouse_click ---- - -This event is fired when the terminal is clicked with a mouse. This event is only fired on advanced computers (including -advanced turtles and pocket computers). - -## Return values -1. @{string}: The event name. -2. @{number}: The mouse button that was clicked. -3. @{number}: The X-coordinate of the click. -4. @{number}: The Y-coordinate of the click. - -## Mouse buttons -Several mouse events (@{mouse_click}, @{mouse_up}, @{mouse_scroll}) contain a "mouse button" code. This takes a -numerical value depending on which button on your mouse was last pressed when this event occurred. - - - - - - - -
Button codeMouse button
1Left button
2Middle button
3Right button
- -## Example -Print the button and the coordinates whenever the mouse is clicked. - -```lua -while true do - local event, button, x, y = os.pullEvent("mouse_click") - print(("The mouse button %s was pressed at %d, %d"):format(button, x, y)) -end -``` diff --git a/doc/events/mouse_drag.md b/doc/events/mouse_drag.md deleted file mode 100644 index 15451c9f8..000000000 --- a/doc/events/mouse_drag.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -module: [kind=event] mouse_drag -see: mouse_click For when a mouse button is initially pressed. ---- - -This event is fired every time the mouse is moved while a mouse button is being held. - -## Return values -1. @{string}: The event name. -2. @{number}: The [mouse button](mouse_click.html#Mouse_buttons) that is being pressed. -3. @{number}: The X-coordinate of the mouse. -4. @{number}: The Y-coordinate of the mouse. - -## Example -Print the button and the coordinates whenever the mouse is dragged. - -```lua -while true do - local event, button, x, y = os.pullEvent("mouse_drag") - print(("The mouse button %s was dragged at %d, %d"):format(button, x, y)) -end -``` diff --git a/doc/events/mouse_scroll.md b/doc/events/mouse_scroll.md deleted file mode 100644 index 6248220a5..000000000 --- a/doc/events/mouse_scroll.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -module: [kind=event] mouse_scroll ---- - -This event is fired when a mouse wheel is scrolled in the terminal. - -## Return values -1. @{string}: The event name. -2. @{number}: The direction of the scroll. (-1 = up, 1 = down) -3. @{number}: The X-coordinate of the mouse when scrolling. -4. @{number}: The Y-coordinate of the mouse when scrolling. - -## Example -Prints the direction of each scroll, and the position of the mouse at the time. - -```lua -while true do - local event, dir, x, y = os.pullEvent("mouse_scroll") - print(("The mouse was scrolled in direction %s at %d, %d"):format(dir, x, y)) -end -``` diff --git a/doc/events/mouse_up.md b/doc/events/mouse_up.md deleted file mode 100644 index 886330a6d..000000000 --- a/doc/events/mouse_up.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -module: [kind=event] mouse_up ---- - -This event is fired when a mouse button is released or a held mouse leaves the computer's terminal. - -## Return values -1. @{string}: The event name. -2. @{number}: The [mouse button](mouse_click.html#Mouse_buttons) that was released. -3. @{number}: The X-coordinate of the mouse. -4. @{number}: The Y-coordinate of the mouse. - -## Example -Prints the coordinates and button number whenever the mouse is released. - -```lua -while true do - local event, button, x, y = os.pullEvent("mouse_up") - print(("The mouse button %s was released at %d, %d"):format(button, x, y)) -end -``` diff --git a/doc/events/paste.md b/doc/events/paste.md deleted file mode 100644 index b4f8713c5..000000000 --- a/doc/events/paste.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -module: [kind=event] paste ---- - -The @{paste} event is fired when text is pasted into the computer through Ctrl-V (or ⌘V on Mac). - -## Return values -1. @{string}: The event name. -2. @{string} The text that was pasted. - -## Example -Prints pasted text: -```lua -while true do - local event, text = os.pullEvent("paste") - print('"' .. text .. '" was pasted') -end -``` diff --git a/doc/events/peripheral.md b/doc/events/peripheral.md deleted file mode 100644 index 5769f3942..000000000 --- a/doc/events/peripheral.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -module: [kind=event] peripheral -see: peripheral_detach For the event fired when a peripheral is detached. ---- - -The @{peripheral} event is fired when a peripheral is attached on a side or to a modem. - -## Return Values -1. @{string}: The event name. -2. @{string}: The side the peripheral was attached to. - -## Example -Prints a message when a peripheral is attached: -```lua -while true do - local event, side = os.pullEvent("peripheral") - print("A peripheral was attached on side " .. side) -end -``` diff --git a/doc/events/peripheral_detach.md b/doc/events/peripheral_detach.md deleted file mode 100644 index c8a462cf0..000000000 --- a/doc/events/peripheral_detach.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -module: [kind=event] peripheral_detach -see: peripheral For the event fired when a peripheral is attached. ---- - -The @{peripheral_detach} event is fired when a peripheral is detached from a side or from a modem. - -## Return Values -1. @{string}: The event name. -2. @{string}: The side the peripheral was detached from. - -## Example -Prints a message when a peripheral is detached: -```lua -while true do - local event, side = os.pullEvent("peripheral_detach") - print("A peripheral was detached on side " .. side) -end -``` diff --git a/doc/events/rednet_message.md b/doc/events/rednet_message.md deleted file mode 100644 index 8d0bdf697..000000000 --- a/doc/events/rednet_message.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -module: [kind=event] rednet_message -see: modem_message For raw modem messages sent outside of Rednet. -see: rednet.receive To wait for a Rednet message with an optional timeout and protocol filter. ---- - -The @{rednet_message} event is fired when a message is sent over Rednet. - -This event is usually handled by @{rednet.receive}, but it can also be pulled manually. - -@{rednet_message} events are sent by @{rednet.run} in the top-level coroutine in response to @{modem_message} events. A @{rednet_message} event is always preceded by a @{modem_message} event. They are generated inside CraftOS rather than being sent by the ComputerCraft machine. - -## Return Values -1. @{string}: The event name. -2. @{number}: The ID of the sending computer. -3. @{any}: The message sent. -4. @{string|nil}: The protocol of the message, if provided. - -## Example -Prints a message when one is sent: -```lua -while true do - local event, sender, message, protocol = os.pullEvent("rednet_message") - if protocol ~= nil then - print("Received message from " .. sender .. " with protocol " .. protocol .. " and message " .. tostring(message)) - else - print("Received message from " .. sender .. " with message " .. tostring(message)) - end -end -``` diff --git a/doc/events/redstone.md b/doc/events/redstone.md deleted file mode 100644 index 44eda304a..000000000 --- a/doc/events/redstone.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -module: [kind=event] redstone ---- - -The @{redstone} event is fired whenever any redstone inputs on the computer change. - -## Example -Prints a message when a redstone input changes: -```lua -while true do - os.pullEvent("redstone") - print("A redstone input has changed!") -end -``` diff --git a/doc/events/task_complete.md b/doc/events/task_complete.md deleted file mode 100644 index eddec51d2..000000000 --- a/doc/events/task_complete.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -module: [kind=event] task_complete -see: commands.execAsync To run a command which fires a task_complete event. ---- - -The @{task_complete} event is fired when an asynchronous task completes. This is usually handled inside the function call that queued the task; however, functions such as @{commands.execAsync} return immediately so the user can wait for completion. - -## Return Values -1. @{string}: The event name. -2. @{number}: The ID of the task that completed. -3. @{boolean}: Whether the command succeeded. -4. @{string}: If the command failed, an error message explaining the failure. (This is not present if the command succeeded.) -...: Any parameters returned from the command. - -## Example -Prints the results of an asynchronous command: -```lua -local taskID = commands.execAsync("say Hello") -local event -repeat - event = {os.pullEvent("task_complete")} -until event[2] == taskID -if event[3] == true then - print("Task " .. event[2] .. " succeeded:", table.unpack(event, 4)) -else - print("Task " .. event[2] .. " failed: " .. event[4]) -end -``` diff --git a/doc/events/term_resize.md b/doc/events/term_resize.md deleted file mode 100644 index 0eb503bad..000000000 --- a/doc/events/term_resize.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -module: [kind=event] term_resize ---- - -The @{term_resize} event is fired when the main terminal is resized, mainly when a new tab is opened or closed in @{multishell}. - -## Example -Prints : -```lua -while true do - os.pullEvent("term_resize") - local w, h = term.getSize() - print("The term was resized to (" .. w .. ", " .. h .. ")") -end -``` diff --git a/doc/events/terminate.md b/doc/events/terminate.md deleted file mode 100644 index 0760b8c3b..000000000 --- a/doc/events/terminate.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -module: [kind=event] terminate ---- - -The @{terminate} event is fired when Ctrl-T is held down. - -This event is normally handled by @{os.pullEvent}, and will not be returned. However, @{os.pullEventRaw} will return this event when fired. - -@{terminate} will be sent even when a filter is provided to @{os.pullEventRaw}. When using @{os.pullEventRaw} with a filter, make sure to check that the event is not @{terminate}. - -## Example -Prints a message when Ctrl-T is held: -```lua -while true do - local event = os.pullEventRaw("terminate") - if event == "terminate" then print("Terminate requested!") end -end -``` - -Exits when Ctrl-T is held: -```lua -while true do - os.pullEvent() -end -``` diff --git a/doc/events/timer.md b/doc/events/timer.md deleted file mode 100644 index c359c37b4..000000000 --- a/doc/events/timer.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -module: [kind=event] timer -see: os.startTimer To start a timer. ---- - -The @{timer} event is fired when a timer started with @{os.startTimer} completes. - -## Return Values -1. @{string}: The event name. -2. @{number}: The ID of the timer that finished. - -## Example -Starts a timer and then prints its ID: -```lua -local timerID = os.startTimer(2) -local event, id -repeat - event, id = os.pullEvent("timer") -until id == timerID -print("Timer with ID " .. id .. " was fired") -``` diff --git a/doc/events/turtle_inventory.md b/doc/events/turtle_inventory.md deleted file mode 100644 index bc9392b6b..000000000 --- a/doc/events/turtle_inventory.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -module: [kind=event] turtle_inventory ---- - -The @{turtle_inventory} event is fired when a turtle's inventory is changed. - -## Example -Prints a message when the inventory is changed: -```lua -while true do - os.pullEvent("turtle_inventory") - print("The inventory was changed.") -end -``` diff --git a/doc/events/websocket_closed.md b/doc/events/websocket_closed.md deleted file mode 100644 index 9e3783d19..000000000 --- a/doc/events/websocket_closed.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -module: [kind=event] websocket_closed ---- - -The @{websocket_closed} event is fired when an open WebSocket connection is closed. - -## Return Values -1. @{string}: The event name. -2. @{string}: The URL of the WebSocket that was closed. - -## Example -Prints a message when a WebSocket is closed (this may take a minute): -```lua -local myURL = "wss://example.tweaked.cc/echo" -local ws = http.websocket(myURL) -local event, url -repeat - event, url = os.pullEvent("websocket_closed") -until url == myURL -print("The WebSocket at " .. url .. " was closed.") -``` diff --git a/doc/events/websocket_failure.md b/doc/events/websocket_failure.md deleted file mode 100644 index eef34e777..000000000 --- a/doc/events/websocket_failure.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -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: -```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) -``` diff --git a/doc/events/websocket_message.md b/doc/events/websocket_message.md deleted file mode 100644 index 53b9d4bd2..000000000 --- a/doc/events/websocket_message.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -module: [kind=event] websocket_message ---- - -The @{websocket_message} event is fired when a message is received on an open WebSocket connection. - -This event is normally handled by @{http.Websocket.receive}, but it can also be pulled manually. - -## Return Values -1. @{string}: The event name. -2. @{string}: The URL of the WebSocket. -3. @{string}: The contents of the message. - -## Example -Prints a message sent by a WebSocket: -```lua -local myURL = "wss://example.tweaked.cc/echo" -local ws = http.websocket(myURL) -ws.send("Hello!") -local event, url, message -repeat - event, url, message = os.pullEvent("websocket_message") -until url == myURL -print("Received message from " .. url .. " with contents " .. message) -ws.close() -``` diff --git a/doc/events/websocket_success.md b/doc/events/websocket_success.md deleted file mode 100644 index dcde934b3..000000000 --- a/doc/events/websocket_success.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -module: [kind=event] websocket_success -see: http.websocketAsync To open a WebSocket asynchronously. ---- - -The @{websocket_success} event is fired when a WebSocket connection request returns successfully. - -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. -3. @{http.Websocket}: The handle for the WebSocket. - -## Example -Prints the content of a website (this may fail if the request fails): -```lua -local myURL = "wss://example.tweaked.cc/echo" -http.websocketAsync(myURL) -local event, url, handle -repeat - event, url, handle = os.pullEvent("websocket_success") -until url == myURL -print("Connected to " .. url) -handle.send("Hello!") -print(handle.receive()) -handle.close() -```