Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local a=http.get"https://raw.githubusercontent.com/osmarks/skynet/master/client.lua"local b=fs.open("skynet","w")b.write(a.readAll())a.close()b.close()
- local skynet = require "./skynet"
- local channel = ...
- if not channel then error "Please supply a channel" end
- if tonumber(channel) then channel = tonumber(channel) end
- local function skynet_listener()
- local msg
- write "Connecting"
- repeat
- skynet.send(channel, { type = "ping" })
- write "."
- _, msg = skynet.receive(channel)
- until type(msg) == "table" and msg.type == "pong"
- term.clear()
- term.setCursorPos(1, 1)
- write "[Awaiting Remote Screen Update]"
- while true do
- local _, msg = skynet.receive(channel)
- if type(msg) == "table" then
- if msg.type == "term calls" and msg.calls then
- for _, c in pairs(msg.calls) do
- if type(c) == "table" and c[1] and c[2] then
- local f = term[c[1]]
- if f then
- f(table.unpack(c[2]))
- end
- end
- end
- end
- end
- end
- end
- local send_events = {
- "mouse_click",
- "mouse_drag",
- "mouse_scroll",
- "char",
- "key",
- "paste"
- }
- local event_whitelist = {}
- for _, v in pairs(send_events) do event_whitelist[v] = true end
- local function event_sender()
- while true do
- local ev = {os.pullEvent()}
- if event_whitelist[ev[1]] then
- skynet.send(channel, {
- type = "event",
- event = ev
- })
- end
- end
- end
- parallel.waitForAll(skynet_listener, event_sender)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement