diff options
author | 2019-11-16 14:57:35 -0600 | |
---|---|---|
committer | 2019-11-16 14:59:02 -0600 | |
commit | b0ef759b80013332d8d19e954dd6330d76593602 (patch) | |
tree | 7ec1c0935d2eb0d9ad1779bcf1ae962eef7dcca0 /plugins/discord/init.lua | |
parent | dd86e8408c7ea56ff0999b6a880348f9891f2632 (diff) |
winptty: don't create pipe unless requested (nw)
plugins/discord: disconnect if timed out (nw)
Diffstat (limited to 'plugins/discord/init.lua')
-rw-r--r-- | plugins/discord/init.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/discord/init.lua b/plugins/discord/init.lua index 21ec88ec79a..5e5ce88a514 100644 --- a/plugins/discord/init.lua +++ b/plugins/discord/init.lua @@ -40,9 +40,13 @@ function discord.startplugin() if data:find("code", 1, true) then error("discord: bad RPC reply, " .. data:sub(8) .. "\n") end + if #data == 0 then + error("discord: timed out waiting for response\n"); + end end local function update(status) + if not pipe then return end local running = emu.romname() ~= "___empty" local state = not running and "In menu" or status local details = running and manager:machine():system().description or nil @@ -78,13 +82,18 @@ function discord.startplugin() local res = pipe:read(100) data = data .. res until #res == 0 and #data > 0 or time + 1 < os.time() + if #data == 0 then + emu.print_verbose("discord: timed out waiting for response, closing connection\n"); + pipe = nil + end --print(data) end do local stat, err = pcall(init) if not stat then - emu.print_error(err) + emu.print_verbose(err) + pipe = nil return end end |