1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-20 18:27:40 +00:00

networking improvements

This commit is contained in:
kepler155c@gmail.com
2017-05-10 06:11:25 -04:00
parent f866d2bd58
commit 3a922ad2f4
10 changed files with 97 additions and 57 deletions

View File

@@ -71,6 +71,19 @@ function socketClass:write(data)
return true
end
function socketClass:ping()
if not self.connected then
Logger.log('socket', 'ping: No connection')
return false
end
transport.write(self, {
type = 'PING',
seq = self.wseq,
data = data,
})
return true
end
function socketClass:close()
if self.connected then
Logger.log('socket', 'closing socket ' .. self.sport)

View File

@@ -154,10 +154,11 @@ function Terminal.readPassword(prompt)
if prompt then
term.write(prompt)
end
local fn = term.write
term.write = function() end
local s = read(prompt)
term.write = fn
local fn = term.current().write
term.current().write = function() end
local s
pcall(function() s = read(prompt) end)
term.current().write = fn
if s == '' then
return

View File

@@ -103,6 +103,14 @@ function Util.keys(t)
return keys
end
function Util.invert(t)
local nt = { }
for k,v in pairs(t) do
nt[v] = k
end
return nt
end
function Util.merge(obj, args)
if args then
for k,v in pairs(args) do