On Mon, Aug 29, 2005 at 08:12:09PM +1000, Trejkaz wrote:
> On Mon, 29 Aug 2005 19:31, Ralph Meijer wrote:
> > On Sun, Aug 28, 2005 at 11:42:25AM -0700, Ralph Giles wrote:
> > > I'd like to collect suggestions for "cancelling" an in-process iq
> > > transaction.
> >
> > I would also go with a similar approach as yours. An <iq/> for the
> > transaction request and a <message/> with the results when the
> > transaction is completed. The two then matched up by a application
> > specific handle. There is no generic solution to the pattern you
> > describe, yet.
> 
> The difficulty with that approach, of course, is that it can't possibly with 
> with existing, standard IQ queries.  I don't suppose we need some kind of <iq 
> type='cancel'/> where you pass the same ID of the query you want to cancel...

Ehm, yes, that's what Ralph en Ralph said. There is no generic solution,
so far, but you could do this like:

Client sends request:

<iq from='[EMAIL PROTECTED]/client'
    to='service.example.com'
    type='set' id='H_2'>
  <transaction xmlns='http://example.com/transaction'>
    <query id='query_5'>
      ...
    </query>
  </transaction>
</iq>

Service responds with "Ok, I'm doing this":

<iq from='service.example.com'
    to='[EMAIL PROTECTED]/client'
    type='result' id='H_2'/>

And, then when the result is done:

<message from='service.example.com'
         to='[EMAIL PROTECTED]/client'>
  <results xmlns='http://example.com/transaction#results' id='query_5'>
    ...
  </results>
</message>

If you want to cancel in the middle of processing you can just send:

<iq from='[EMAIL PROTECTED]/client'
    to='service.example.com'
    type='set' id='H_3'>
  <transaction xmlns='http://example.com/transaction'>
    <cancel id='query_5'/>
  </transaction>
</iq>

Yielding:

<iq from='service.example.com'
    to='[EMAIL PROTECTED]/client'
    type='result' id='H_3'/>

or in case of an error (nicely annotated with a machine readable
construct and a diagnostic text for humans):

<iq from='service.example.com'
    to='[EMAIL PROTECTED]/client'
    type='error' id='H_3'>
  <transaction xmlns='http://example.com/transaction'>
    <cancel id='query_5'/>
  </transaction>
  <error type='cancel'>
    <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    <completed xmlns='http://example.com/transaction#error'/>
    <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='en'>
      The referenced query has already been completed and cannot be
      cancelled.
    </text>
  </error>
</iq>

-- 
Groetjes,

ralphm
_______________________________________________
jdev mailing list
[email protected]
http://mail.jabber.org/mailman/listinfo/jdev

Reply via email to