Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local json = dofile('json.lua')
- local surface = dofile('surface.lua')
- local monitor = peripheral.find('monitor')
- local w, h = monitor.getSize()
- local screen = surface.create(w, h)
- local LibDeflate = dofile('LibDeflate.lua')
- local function start()
- local ws, err = http.websocket('ws://127.0.0.1:3000/attach')
- if err then
- print(err)
- elseif ws then
- while true do
- -- Request draw from server
- ws.send(json.encode({type = 'REQUEST_DRAW'}))
- -- Wait for frame
- while true do
- local response = json.decode(ws.receive())
- if response.type == 'ERROR' then
- -- Message we recieved was an error of some sort, log it
- print('[ERROR] ' .. response.error)
- elseif response.type == 'SCREEN_DRAW' then
- local output = LibDeflate:DecompressZlib(response.screen)
- local surf = surface.load(output, true)
- surf:toPalette(surface.palette.cc, true)
- screen:drawSurfaceSmall(surf, 0, 0)
- screen:output(monitor)
- break
- end
- end
- end
- end
- end
- start()
Add Comment
Please, Sign In to add comment