#714 Prosody Stateful Asynchronous API for sending IQ

Reporter Eugene Voityuk
Owner Nobody
Created
Updated
Stars ★ (1)  
Tags
  • Status-New
  • Type-Enhancement
  • Priority-Medium
  1. Eugene Voityuk on

    Prosody Stateful Asynchronous API for sending IQ Code name: IQ Tracker :) Purpose Historically happened that prosody lacks an easy mechanism to send iq from server, and keep track of their result, this draft aims to solve this by introducing new API functionality. Implementation For API usage you need to create an instance of IQ Tracker, each instance takes limit and timeout as arguments. Timeout is a number of second to wait for an iq response and drop iq’s that was not responded in specified time. Limit aims to prevent different DDoS attacks, as each iq request using this api will be tracked in memory, until response will be received, or timeout will expire. API will create an instance and will return a function, that will be used to send iq’s. Function takes three arguments, first is a valid iq to send, second is callback, and the this is a key. Key is any string that will be used to keep track of limits, so if you set limit=5, each key may hold 5 open iq stanzas. Usage local send_iq = require ”util.iq_tracker”.create_tracker(limit,timeout); local generic_iq = st.iq({ from = “juliet@example.com” to = ‘romeo@example.net’, type = “set” }) send_iq(generic_iq, function(res, err) If err then module:log(“debug”, ”Failed to send stanza, error type %s, error condition %s, err.type, err.condition); end end, generic_iq.attr.from)

New comment