cleanup + global clipboard

This commit is contained in:
kepler155c@gmail.com
2017-10-11 22:39:04 -04:00
parent f9221e67be
commit 3460dd68b2
6 changed files with 59 additions and 87 deletions

View File

@@ -1,58 +1,43 @@
local device = _G.device
local multishell = _ENV.multishell
local os = _G.os
local parallel = _G.parallel
if device.wireless_modem then
multishell.setTitle(multishell.getCurrent(), 'Chat Daemon')
multishell.setTitle(multishell.getCurrent(), 'Chat')
local tab
multishell.openTab({
path = 'rom/programs/rednet/chat',
args = { 'host', 'opusChat-' .. os.getComputerID() },
title = 'Chat Daemon',
hidden = true,
})
local function chatClient()
local tab = multishell.getTab(multishell.getCurrent())
_G.requireInjector()
_G.requireInjector()
local Event = require('event')
local Util = require('util')
local h = Event.addRoutine(function()
while true do
Util.run(_ENV, 'rom/programs/rednet/chat',
'join', 'opusChat-' .. os.getComputerID(), 'owner')
end
end)
local Event = require('event')
local Util = require('util')
local h = Event.addRoutine(function()
while true do
local e = { os.pullEventRaw() }
if e[1] == 'terminate' then
multishell.hideTab(tab.tabId)
else
if e[1] == 'rednet_message' and e[4] == 'chat' and e[3].sType == 'chat' then
if tab.hidden then
multishell.unhideTab(tab.tabId)
end
Util.run(_ENV, 'rom/programs/rednet/chat',
'join', 'opusChat-' .. os.getComputerID(), 'owner')
end
end)
while true do
local e = { os.pullEventRaw() }
if e[1] == 'terminate' then
multishell.hideTab(tab.tabId)
else
if e[1] == 'rednet_message' and e[4] == 'chat' and e[3].sType == 'chat' then
if tab.hidden then
multishell.unhideTab(tab.tabId)
end
h:resume(unpack(e))
end
h:resume(table.unpack(e))
end
end
parallel.waitForAll(
function()
os.run(_ENV, 'rom/programs/rednet/chat',
'host', 'opusChat-' .. os.getComputerID())
end,
function()
os.sleep(3)
local tabId = multishell.openTab({
fn = chatClient,
title = 'Chat',
hidden = true,
})
tab = multishell.getTab(tabId)
end
)
print('Chat daemon stopped')
end