# HG changeset patch # User Kim Alvefur # Date 1645281827 -3600 # Node ID 6d97b42bb1b46310c6a1b0dfb33add361d64e695 # Parent f3ecbf65a81e684dc51a252be8ee497447d5a24f plugins.smacks: Handle failed resumption by trying to bind instead diff -r f3ecbf65a81e -r 6d97b42bb1b4 plugins/smacks.lua --- a/plugins/smacks.lua Sat Nov 06 18:26:31 2021 +0100 +++ b/plugins/smacks.lua Sat Feb 19 15:43:47 2022 +0100 @@ -84,6 +84,7 @@ stream:warn("Received bad ack for "..new_ack.." when last ack was "..last_ack); end elseif stanza.name == "enabled" then + stream.pre_smacks_features = nil; if stanza.attr.id then stream.resumption_token = stanza.attr.id; @@ -91,6 +92,7 @@ stream:hook("disconnected", on_disconnect, 100); end elseif stanza.name == "resumed" then + stream.pre_smacks_features = nil; local new_ack = tonumber(stanza.attr.h); if new_ack > last_ack then local old_unacked = #outgoing_queue; @@ -106,6 +108,20 @@ outgoing_queue = {}; stream:debug("Resumed successfully"); stream:event("resumed"); + elseif stanza.name == "failed" then + stream.bound = nil + stream.smacks = nil + last_ack = 0 + handled_stanza_count = 0; + + -- TODO ack using final h value from if present + outgoing_queue = {}; -- TODO fire some delivery failures + + local features = stream.pre_smacks_features; + stream.pre_smacks_features = nil; + + -- should trigger a bind and then a new smacks session + stream:event("stream-features", features); else stream:warn("Don't know how to handle "..xmlns_sm.."/"..stanza.name); end @@ -126,6 +142,7 @@ local function on_features(features) if features:get_child("sm", xmlns_sm) then + stream.pre_smacks_features = features; stream.stream_management_supported = true; if stream.smacks and stream.bound then -- Already enabled in a previous session - resume stream:debug("Resuming stream with %d handled stanzas", handled_stanza_count);