Repository navigation
0.4.0
Added
-
Web Sockets
netnow 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.servefunction.
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.servenow returns aNetServeHandlewhich 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.spawnis now a global typeProcessSpawnOptions. -
Setting
cwdin the options forprocess.spawnto a path starting with a tilde (~) will now use a path relative to the platform-specific home / user directory. -
NetRequestquery 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.requestnow 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.spawnblocking all lua threads if the spawned child process yields.