mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 04:50:36 +00:00
Fix websocket example files
This commit is contained in:
parent
f89d02a60d
commit
ef294f207c
2 changed files with 5 additions and 5 deletions
|
@ -28,8 +28,8 @@ end)
|
||||||
|
|
||||||
for _ = 1, 5 do
|
for _ = 1, 5 do
|
||||||
local start = os.clock()
|
local start = os.clock()
|
||||||
socket.send(tostring(1))
|
socket:send(tostring(1))
|
||||||
local response = socket.next()
|
local response = socket:next()
|
||||||
local elapsed = os.clock() - start
|
local elapsed = os.clock() - start
|
||||||
print(`Got response '{response}' in {elapsed * 1_000} milliseconds`)
|
print(`Got response '{response}' in {elapsed * 1_000} milliseconds`)
|
||||||
task.wait(1 - elapsed)
|
task.wait(1 - elapsed)
|
||||||
|
@ -38,7 +38,7 @@ end
|
||||||
-- Everything went well, and we are done with the socket, so we can close it
|
-- Everything went well, and we are done with the socket, so we can close it
|
||||||
|
|
||||||
print("Closing web socket...")
|
print("Closing web socket...")
|
||||||
socket.close()
|
socket:close()
|
||||||
|
|
||||||
task.cancel(forceExit)
|
task.cancel(forceExit)
|
||||||
print("Done! 🌙")
|
print("Done! 🌙")
|
||||||
|
|
|
@ -15,9 +15,9 @@ local handle = net.serve(PORT, {
|
||||||
handleWebSocket = function(socket)
|
handleWebSocket = function(socket)
|
||||||
print("Got new web socket connection!")
|
print("Got new web socket connection!")
|
||||||
repeat
|
repeat
|
||||||
local message = socket.next()
|
local message = socket:next()
|
||||||
if message ~= nil then
|
if message ~= nil then
|
||||||
socket.send("Echo - " .. message)
|
socket:send("Echo - " .. message)
|
||||||
end
|
end
|
||||||
until message == nil
|
until message == nil
|
||||||
print("Web socket disconnected.")
|
print("Web socket disconnected.")
|
||||||
|
|
Loading…
Reference in a new issue