Created
September 7, 2024 05:07
-
-
Save damp11113/86ce4dac05a3d1d8caef2afa894e01c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ws = assert(http.websocket("ws://127.0.0.1:5133")) | |
print("connected to server") | |
local id | |
local isrunning = true | |
function exitcheck() | |
while true do | |
local event = os.pullEventRaw("terminate") | |
if event == "terminate" then | |
print("Exiting...") | |
isrunning = false | |
ws.close() | |
break | |
end | |
end | |
end | |
function main() | |
while isrunning do | |
print("ready") | |
local message, error = ws.receive() | |
if message then | |
print("Received message:", message) | |
else | |
print("WebSocket error:", error) | |
break | |
end | |
end | |
end | |
parallel.waitForAny(exitcheck, main) | |
print("Exited") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment