Fix websocket example files

This commit is contained in:
Filip Tibell 2024-10-17 11:27:32 +02:00
parent f89d02a60d
commit ef294f207c
No known key found for this signature in database
2 changed files with 5 additions and 5 deletions

View file

@ -28,8 +28,8 @@ end)
for _ = 1, 5 do
local start = os.clock()
socket.send(tostring(1))
local response = socket.next()
socket:send(tostring(1))
local response = socket:next()
local elapsed = os.clock() - start
print(`Got response '{response}' in {elapsed * 1_000} milliseconds`)
task.wait(1 - elapsed)
@ -38,7 +38,7 @@ end
-- Everything went well, and we are done with the socket, so we can close it
print("Closing web socket...")
socket.close()
socket:close()
task.cancel(forceExit)
print("Done! 🌙")

View file

@ -15,9 +15,9 @@ local handle = net.serve(PORT, {
handleWebSocket = function(socket)
print("Got new web socket connection!")
repeat
local message = socket.next()
local message = socket:next()
if message ~= nil then
socket.send("Echo - " .. message)
socket:send("Echo - " .. message)
end
until message == nil
print("Web socket disconnected.")