package cleanup

This commit is contained in:
kepler155c@gmail.com
2018-12-10 10:33:10 -05:00
parent 37ffae42bd
commit bf3983a7e2
11 changed files with 21 additions and 35 deletions

52
monitor/mirrorHost.lua Normal file
View File

@@ -0,0 +1,52 @@
_G.requireInjector()
local Event = require('event')
local Logger = require('logger')
local Socket = require('socket')
local colors = _G.colors
local term = _G.term
Logger.setScreenLogging()
local mon = term.current()
local args = { ... }
if args[1] then
mon = _G.device[args[1]]
end
if not mon then
error('Invalid monitor')
end
mon.setBackgroundColor(colors.black)
mon.clear()
while true do
local socket = Socket.server(5901)
print('mirror: connection from ' .. socket.dhost)
Event.addRoutine(function()
while true do
local data = socket:read()
if not data then
break
end
for _,v in ipairs(data) do
mon[v.f](unpack(v.args))
end
end
end)
while true do
Event.pullEvent()
if not socket.connected then
break
end
end
print('connection lost')
socket:close()
end