Hey Everyone,

I've been looking into Vysper-18, 'Recognize and act upon closing stream tag'.  
I think I have a fix for it, but I wanted to get some input before doing a 
commit.  Here is what I'm doing:

1. I noticed that XMLParser successfully determines the end of the stream 
document on lines 482-484, and notifies its content handler.

2. The Parser's content handler, XMPPContentHandler, ignores the endDocument() 
call.  Instead of just ignoring it, I modified the XMLElementListener interface 
to be as follows:
        
 public interface XMLElementListener {
   void element(XMLElement element);
   void close();
   boolean isClosed();
 }

and implemented this updated interface in XMPPDecoder.MinaStanzaListener.  I 
then gave the MinaStanzaListener a boolean closed field so it could track its 
state.

3. In XMPPDecoder.doDecode() I modified the end of the method as follows:

 XMPPContentHandler contentHandler = (XMPPContentHandler) 
reader.getContentHandler();
 XMLElementListener listener = new MinaStanzaListener(out);
 contentHandler.setListener(listener);

 reader.parse(in, CharsetUtil.UTF8_DECODER);  // If parsing find the end of the 
document, then the listener's close() will be called.
        
 if (listener.isClosed()) {
   session.close(false);
   return true;
 } else {
   // we have parsed what we got, invoke again when more data is available
   return false;
 }

The call to session.close() then triggers the sessionClosed() handler in 
XmppIoHandlerAdapter, which cleans up the Vysper SessionContext.

I'm particularly looking for any thoughts on the session closing.  I'm not a 
Mina expert by any means, so I want to make sure the close in 
XMPPDecoder.doDecode() handles everything cleanly.  I realize this doesn't 
handle the BOSH case, but I can tackle that next.

Thanks for any input,
Mike


----------------------------------------
Mike Mahoney
OEM Application Specialist
ThingWorx
Office:   (610) 594-6200 x817
Mobile: (585) 314-8592

Reply via email to