Add a delegate for incoming/outgoing elements.
This commit is contained in:
parent
4aaa754a4d
commit
fdf33f356a
3 changed files with 25 additions and 2 deletions
|
@ -40,6 +40,10 @@
|
||||||
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
|
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
|
||||||
@optional
|
@optional
|
||||||
#endif
|
#endif
|
||||||
|
- (void)connection: (XMPPConnection*)connection
|
||||||
|
didReceiveElement: (OFXMLElement*)element;
|
||||||
|
- (void)connection: (XMPPConnection*)connection
|
||||||
|
didSendElement: (OFXMLElement*)element;
|
||||||
- (void)connectionWasAuthenticated: (XMPPConnection*)connection;
|
- (void)connectionWasAuthenticated: (XMPPConnection*)connection;
|
||||||
- (void)connection: (XMPPConnection*)connection
|
- (void)connection: (XMPPConnection*)connection
|
||||||
wasBoundToJID: (XMPPJID*)JID;
|
wasBoundToJID: (XMPPJID*)JID;
|
||||||
|
|
|
@ -344,7 +344,11 @@
|
||||||
|
|
||||||
- (void)sendStanza: (OFXMLElement*)element
|
- (void)sendStanza: (OFXMLElement*)element
|
||||||
{
|
{
|
||||||
of_log(@"Out: %@", element);
|
if ([delegate respondsToSelector:
|
||||||
|
@selector(connection:didSendElement:)])
|
||||||
|
[delegate connection: self
|
||||||
|
didSendElement: element];
|
||||||
|
|
||||||
[sock writeString: [element XMLString]];
|
[sock writeString: [element XMLString]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +408,10 @@
|
||||||
[element setPrefix: @"stream"
|
[element setPrefix: @"stream"
|
||||||
forNamespace: XMPP_NS_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])
|
if ([[element namespace] isEqual: XMPP_NS_CLIENT])
|
||||||
[self XMPP_handleStanza: element];
|
[self XMPP_handleStanza: element];
|
||||||
|
|
12
tests/test.m
12
tests/test.m
|
@ -111,6 +111,18 @@ OF_APPLICATION_DELEGATE(AppDelegate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (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
|
- (void)connectionWasAuthenticated: (XMPPConnection*)conn
|
||||||
{
|
{
|
||||||
of_log(@"Auth successful");
|
of_log(@"Auth successful");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue