Index: src/XMPPConnection.h ================================================================== --- src/XMPPConnection.h +++ src/XMPPConnection.h @@ -88,10 +88,13 @@ @property (assign) uint16_t port; @property (retain) id delegate; @property (readonly, retain) XMPPRoster *roster; #endif +/** + * \return A new autoreleased XMPPConnection + */ + connection; /** * Connects to the XMPP service. */ @@ -100,10 +103,22 @@ /** * Starts a loop handling incomming data. */ - (void)handleConnection; +/** + * Parses the specified buffer. + * + * This is useful for handling multiple connections at once. + * + * \param buf The buffer to parse + * \param size The size of the buffer. If size is 0, it is assumed that the + * connection was closed. + */ +- (void)parseBuffer: (const char*)buf + withSize: (size_t)size; + /** * Sends an OFXMLElement, usually an XMPPStanza. * * \param elem The element to send */ Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -226,10 +226,21 @@ [parser parseBuffer: buf withSize: len]; } } + +- (void)parseBuffer: (const char*)buf + withSize: (size_t)size +{ + if (size < 1 && [delegate respondsToSelector: + @selector(connectionWasClosed:)]) + [delegate connectionWasClosed: self]; + + [parser parseBuffer: buf + withSize: size]; +} - (void)sendStanza: (OFXMLElement*)elem { of_log(@"Out: %@", elem); [sock writeString: [elem XMLString]];