mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
refactor 'wss-rw' into a functional test for lune cargo tests
This commit is contained in:
parent
2ac5a0380d
commit
ee6fd5d886
1 changed files with 10 additions and 7 deletions
|
@ -7,20 +7,23 @@ local task = require("@lune/task")
|
||||||
-- as well as write to the same stream concurrently
|
-- as well as write to the same stream concurrently
|
||||||
local socket = net.socket("wss://gateway.discord.gg/?v=10&encoding=json")
|
local socket = net.socket("wss://gateway.discord.gg/?v=10&encoding=json")
|
||||||
|
|
||||||
task.spawn(function()
|
local spawnedThread = task.spawn(function()
|
||||||
while not socket.closeCode do
|
while not socket.closeCode do
|
||||||
socket.next()
|
socket.next()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
task.delay(1, function()
|
local delayedThread = task.delay(5, function()
|
||||||
socket.send('{"op":1,"d":null}')
|
task.defer(process.exit, 1)
|
||||||
socket.close(1000)
|
error("`socket.send` halted, failed to write to socket")
|
||||||
|
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
task.wait(5)
|
task.wait(1)
|
||||||
|
|
||||||
task.defer(process.exit, 1)
|
socket.send('{"op":1,"d":null}')
|
||||||
error("`socket.send` halted, failed to write to socket")
|
socket.close(1000)
|
||||||
|
|
||||||
|
task.cancel(delayedThread)
|
||||||
|
task.cancel(spawnedThread)
|
Loading…
Add table
Reference in a new issue