View difference between Paste ID: RVRbiWgW and qctx4dbx
SHOW: | | - or go back to the newest paste.
1-
local default = "wss://osmarks.ml/ws/"
1+
local key = settings.get "govos.key"
2
if not key then error "GovOS RDS key not found." end
3-
local ws, error, url
3+
local ws, err = http.websocket("wss://osmarks.tk/wsthing/GovOS/admin", {
4
	authorization = "Key " .. key
5-
function connect()
5+
})
6-
	ws, error = http.websocket(url)
6+
7-
	if error then
7+
if err then
8-
		print(error)
8+
	error(err)
9-
	else
9+
else
10-
		print "Connected"
10+
	print "Connected"
11
end
12
13
function readWS()
14-
repeat
14+
15-
	write "URL> "
15+
16-
	url = read()
16+
17
end
18-
	if url == "" then
18+
19-
		print("Defaulted to", default)
19+
20-
		url = default
20+
21
22
	if not ok then
23-
	connect()
23+
24-
until ws
24+
25
		send(msg)
26
	end
27
end
28
29
function writeWS()
30
	local hist = {}
31
	while true do
32
		write "|> "
33
		local input = read(nil, hist)
34
		table.insert(hist, input)
35
		send(input)
36
	end
37
end
38
39
parallel.waitForAll(writeWS, readWS)