Index: src/XMPPConnection.h ================================================================== --- src/XMPPConnection.h +++ src/XMPPConnection.h @@ -38,10 +38,14 @@ #endif #ifdef OF_HAVE_OPTIONAL_PROTOCOLS @optional #endif +- (void)connection: (XMPPConnection*)connection + didReceiveElement: (OFXMLElement*)element; +- (void)connection: (XMPPConnection*)connection + didSendElement: (OFXMLElement*)element; - (void)connectionWasAuthenticated: (XMPPConnection*)connection; - (void)connection: (XMPPConnection*)connection wasBoundToJID: (XMPPJID*)JID; - (void)connectionDidReceiveRoster: (XMPPConnection*)connection; - (BOOL)connection: (XMPPConnection*)connection Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -342,11 +342,15 @@ reason: @"No matching identifier"]; } - (void)sendStanza: (OFXMLElement*)element { - of_log(@"Out: %@", element); + if ([delegate respondsToSelector: + @selector(connection:didSendElement:)]) + [delegate connection: self + didSendElement: element]; + [sock writeString: [element XMLString]]; } - (OFString*)generateStanzaID { @@ -402,11 +406,14 @@ [element setDefaultNamespace: XMPP_NS_CLIENT]; [element setPrefix: @"stream" forNamespace: XMPP_NS_STREAM]; - of_log(@"In: %@", element); + if ([delegate respondsToSelector: + @selector(connection:didReceiveElement:)]) + [delegate connection: self + didReceiveElement: element]; if ([[element namespace] isEqual: XMPP_NS_CLIENT]) [self XMPP_handleStanza: element]; if ([[element namespace] isEqual: XMPP_NS_STREAM]) Index: tests/test.m ================================================================== --- tests/test.m +++ tests/test.m @@ -108,10 +108,22 @@ [conn handleConnection]; } @catch (id e) { of_log(@"%@", e); } } + +- (void)connection: (XMPPConnection*)conn + didReceiveElement: (OFXMLElement*)element +{ + of_log(@"In: %@", element); +} + +- (void)connection: (XMPPConnection*)conn + didSendElement: (OFXMLElement*)element +{ + of_log(@"Out: %@", element); +} - (void)connectionWasAuthenticated: (XMPPConnection*)conn { of_log(@"Auth successful"); }