Поиск по сайту
Результаты поиска по тегам 'OpenViewer'.
Найдено 1 результат
-
Всем привет! В этой теме я расскажу моей программе ---Удалённом рабочем столе на сети OpenNet и моде OpenComputers. Первым делом расскажу как ей пользоваться. Ввод данных: Всё очень просто=) Жмёте на кнопку на клавиатуре, и её нажатие эмитируется на удалённом компьютере. Для обновления экрана --- F5 Для выхода из программы на удалённом компьютере --- F2 Для выхода из программы на локальном компьютере ---F1 Ну....Вроде всё по управлению=) Запуск,настройка и подключение: Подготовка к запуску удалённого терминала: Установить библиотеку thread: local computer = require("computer") computer.SingleThread = computer.pullSignal local thread = {} local mainThread local timeouts local function MultiThread( _timeout ) if coroutine.running()==mainThread then local mintime = _timeout or math.huge local co=next(timeouts) while co do if coroutine.status( co ) == "dead" then timeouts[co],co=nil,next(timeouts,co) else if timeouts[co] < mintime then mintime=timeouts[co] end co=next(timeouts,co) end end if not next(timeouts) then computer.pullSignal=computer.SingleThread computer.pushSignal("AllThreadsDead") end local event={computer.SingleThread(mintime)} local ok, param for co in pairs(timeouts) do ok, param = coroutine.resume( co, table.unpack(event) ) if not ok then timeouts={} error( param ) else timeouts[co] = param or math.huge end end return table.unpack(event) else return coroutine.yield( _timeout ) end end function thread.init() mainThread=coroutine.running() timeouts={} end function thread.create(f,...) computer.pullSignal=MultiThread local co=coroutine.create(f) timeouts[co]=math.huge local ok, param = coroutine.resume( co, ... ) if not ok then timeouts={} error( param ) else timeouts[co] = param or '' end return co end function thread.kill(co) timeouts[co]=nil end function thread.killAll() timeouts={} computer.pullSignal=computer.SingleThread end function thread.waitForAll() repeat until MultiThread()=="AllThreadsDead" end ------------------------------------------------------------------------------- return thread (Только на сервер,на клиенте она не нужна) Установить OpenNet и находится в зоне его покрытия. Установить на сервер его часть: local event= require("event") local thread= require("thread") local opennet= require("opennet") local computer= require("computer") local gpu= require("component").gpu local unicode= require("unicode") local keyboard= require("component").keyboard.address local IP, dis2serv = opennet.getIP() print("Local IP: "..IP) args={...} if args[1]==nil then print("Использование: openviewerS <opennet_ip>") os.exit() end --[[ _, result, reason = opennet.sendrec(args[1], "connecting...") if result==false then print(reason); os.exit() end if args[1]==IP then print("Невозможно инициализировать удалённый доступ со своим устройством.") os.exit() end ]]-- initial=args[1] local function getScreen() screen="" for y=1, 25 do for x=1, 80 do symbol = gpu.get(x, y) screen=screen..symbol end end return screen end local function sendScreen() opennet.send(initial, getScreen()) end function runShell() os.execute("sh") end function reInitial() thread.killAll() thread.init() thread.create(runShell) thread.create(EmulateSignal) thread.waitForAll() end event.listen("Screen", sendScreen) event.listen("Exit", reInitial) function EmulateSignal() while true do opennetIP, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 = opennet.receive() if opennetIP==initial then computer.pushSignal(arg1, keyboard, tonumber(arg3), tonumber(arg4), arg5) end end end thread.init() thread.create(runShell) thread.create(EmulateSignal) thread.waitForAll() Установить на клиент клиентскую часть: local opennet= require("opennet") local term= require("term") local unicode= require("unicode") local event= require("event") args={...} if args[1]==nil then print("Использование: openviewerC <opennet_ip>") os.exit() end initial=args[1] function getScreen() repeat ip, screenRaw=opennet.receive() until ip==initial for sym=1, #screenRaw-160 do io.write(unicode.sub(screenRaw, sym, sym)) end end term.clear() opennet.send(initial, "Screen") getScreen() while true do arg1, arg2, arg3, arg4, arg5 = event.pull() if arg1=="key_down" and arg3==0 and arg4==63 then term.clear() opennet.send(initial, "Screen") getScreen() elseif arg1=="key_down" and arg3==0 and arg4==59 then os.exit() elseif arg1=="key_down" and arg3==0 and arg4==60 then opennet.send(initial, "Exit") else opennet.send(initial, arg1, arg2, arg3, arg4, arg5) end end Для запуска программы надо написать на сервере: openviewerS <IP Адрес клиента> ВНИМАНИЕ!!! Надо ввести именно IP, а не DNS; Единственное поддерживаемое разрешение - 80x25 На клиенте же пишем: openviewerC <IP Адрес сервера> Вот и всё=) Надеюсь,эта программа вам будет полезна ! Неплохо было-бы попасть в вайт-лист