From b0ef759b80013332d8d19e954dd6330d76593602 Mon Sep 17 00:00:00 2001 From: cracyc Date: Sat, 16 Nov 2019 14:57:35 -0600 Subject: winptty: don't create pipe unless requested (nw) plugins/discord: disconnect if timed out (nw) --- plugins/discord/init.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'plugins') 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 -- cgit v1.2.3-70-g09d2