0.4.0
Added
-
Web Sockets
net
now supports web sockets for both clients and servers!
Note that the web socket object is identical on both client and server, but how you retrieve a web socket object is different.Server API
The server web socket API is an extension of the existing
net.serve
function.
This allows for serving both normal HTTP requests and web socket requests on the same port.Example usage:
net.serve(8080, { handleRequest = function(request) return "Hello, world!" end, handleWebSocket = function(socket) task.delay(10, function() socket.send("Timed out!") socket.close() end) -- The message will be nil when the socket has closed repeat local messageFromClient = socket.next() if messageFromClient == "Ping" then socket.send("Pong") end until messageFromClient == nil end, })
Client API
Example usage:
local socket = net.socket("ws://localhost:8080") socket.send("Ping") task.delay(5, function() socket.close() end) -- The message will be nil when the socket has closed repeat local messageFromServer = socket.next() if messageFromServer == "Ping" then socket.send("Pong") end until messageFromServer == nil
Changed
-
net.serve
now returns aNetServeHandle
which can be used to stop serving requests safely.Example usage:
local handle = net.serve(8080, function() return "Hello, world!" end) print("Shutting down after 1 second...") task.wait(1) handle.stop() print("Shut down succesfully")
-
The third and optional argument of
process.spawn
is now a global typeProcessSpawnOptions
. -
Setting
cwd
in the options forprocess.spawn
to a path starting with a tilde (~
) will now use a path relative to the platform-specific home / user directory. -
NetRequest
query parameters value has been changed to be a table of key-value pairs similar toprocess.env
.
If any query parameter is specified more than once in the request url, the value chosen will be the last one that was specified. -
The internal http client for
net.request
now reuses headers and connections for more efficient requests. -
Refactored the Lune rust crate to be much more user-friendly and documented all of the public functions.
Fixed
- Fixed
process.spawn
blocking all lua threads if the spawned child process yields.