diff --git a/src/XMPPConnection.h b/src/XMPPConnection.h index ea3685f..ac03b17 100644 --- a/src/XMPPConnection.h +++ b/src/XMPPConnection.h @@ -90,6 +90,9 @@ @property (readonly, retain) XMPPRoster *roster; #endif +/** + * \return A new autoreleased XMPPConnection + */ + connection; /** @@ -102,6 +105,18 @@ */ - (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. * diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index c130074..f260a4c 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -229,6 +229,17 @@ } } +- (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);