-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenshare.lua
40 lines (37 loc) · 1.1 KB
/
screenshare.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-- Get streamer IP
write("Enter streamer IP: ")
local ip = read()
-- Connect to streamer
http.websocketAsync(ip)
local event, url, handle
repeat
event, url, handle = os.pullEvent("websocket_success")
until url == ip
print("Connected to ".. url)
-- Setup termination handling
local ok, err = pcall(function()
-- Draw frame
function calcScreen(screen, stream)
screen.setTextScale(0.5)
handle.send(stream)
local response, _ = handle.receive()
response = textutils.unserialiseJSON(response)
for line = 1, 81 do
for pixel = 1, 164 do
local c = response[line]:sub(pixel, pixel)
screen.setCursorPos(pixel, line)
screen.setBackgroundColor(colors.fromBlit(tostring(c)))
screen.write(string.char(0))
end
end
end
-- Main Setup
local detectedScreen = peripheral.find("monitor")
write("Enter name of stream: ")
local selectedStream = read()
while true do
calcScreen(detectedScreen, selectedStream)
end
end)
if handle then handle.close() end
assert(ok, err)