~singpolyma/sgx-jmp

decdb1251f6a37d85cab0ec616ba0d193d083fd5 — Stephen Paul Weber 1 year, 1 month ago b64408f
Command cancel rejects the promise

So it won't be taken as next by naive code.
1 files changed, 9 insertions(+), 3 deletions(-)

M sgx_jmp.rb
M sgx_jmp.rb => sgx_jmp.rb +9 -3
@@ 238,11 238,12 @@ message :error? do |m|
end

class SessionManager
	def initialize(blather, id_msg, timeout: 5)
	def initialize(blather, id_msg, timeout: 5, error_if: nil)
		@blather = blather
		@sessions = {}
		@id_msg = id_msg
		@timeout = timeout
		@error_if = error_if
	end

	def promise_for(stanza)


@@ 264,7 265,7 @@ class SessionManager

	def fulfill(stanza)
		id = "#{stanza.from.stripped}/#{stanza.public_send(@id_msg)}"
		if stanza.error?
		if stanza.error? || @error_if&.call(stanza)
			@sessions.delete(id)&.reject(stanza)
		else
			@sessions.delete(id)&.fulfill(stanza)


@@ 273,7 274,12 @@ class SessionManager
end

IQ_MANAGER = SessionManager.new(self, :id)
COMMAND_MANAGER = SessionManager.new(self, :sessionid, timeout: 60 * 60)
COMMAND_MANAGER = SessionManager.new(
	self,
	:sessionid,
	timeout: 60 * 60,
	error_if: ->(s) { s.cancel? }
)
web_register_manager = WebRegisterManager.new

disco_info to: Blather::JID.new(CONFIG[:component][:jid]) do |iq|