1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-24 12:17:40 +00:00

simplify ui

This commit is contained in:
kepler155c@gmail.com
2017-10-11 11:37:52 -04:00
parent 05c99b583a
commit 852ad193f0
11 changed files with 260 additions and 291 deletions

58
sys/services/chat.lua Normal file
View File

@@ -0,0 +1,58 @@
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')
local tab
local function chatClient()
_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)
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
end
h:resume(unpack(e))
end
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 = 'Chatroom',
hidden = true,
})
tab = multishell.getTab(tabId)
end
)
print('Chat daemon stopped')
end