mirror of
https://github.com/damp11113-software/ccIDE.git
synced 2025-04-27 22:48:13 +00:00
remote code
This commit is contained in:
parent
5598295977
commit
770efd438f
34
remote.lua
Normal file
34
remote.lua
Normal file
@ -0,0 +1,34 @@
|
||||
local ws = assert(http.websocket("ws://127.0.0.1:5133"))
|
||||
print("connected to server")
|
||||
|
||||
local id
|
||||
|
||||
while true do
|
||||
print("ready")
|
||||
local message, error = ws.receive()
|
||||
if message then
|
||||
print("Received message:", message)
|
||||
if message == "ping" then
|
||||
ws.send("pong")
|
||||
elseif message == "sendcode" then
|
||||
local file = io.open("main.lua", "w")
|
||||
print("waiting for code")
|
||||
local filedata, error = ws.receive()
|
||||
file:write(filedata)
|
||||
file:close()
|
||||
elseif message == "runcode" then
|
||||
id = multishell.launch({}, "main.lua")
|
||||
multishell.setTitle(id, "Code")
|
||||
multishell.setFocus(id)
|
||||
elseif message == "exit" then
|
||||
print("Exiting...")
|
||||
break
|
||||
end
|
||||
|
||||
else
|
||||
print("WebSocket error:", error)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
ws.close()
|
Loading…
x
Reference in New Issue
Block a user