Make it possible to get exceptions in async mode.

This commit is contained in:
Jonathan Schleifer 2012-11-24 01:36:29 +01:00
parent 334586bb07
commit 6a89ab76d0
2 changed files with 27 additions and 2 deletions

View file

@ -116,6 +116,18 @@
*/ */
- (void)connectionWasClosed: (XMPPConnection*)connection; - (void)connectionWasClosed: (XMPPConnection*)connection;
/**
* \brief This callback is called when the connection threw an exception.
*
* This is only called for connections on which \ref handleConnection: has been
* called.
*
* \param connection The connection which threw an exception
* \param exception The exception the connection threw
*/
- (void)connection: (XMPPConnection*)connection
didThrowException: (OFException*)exception;
/** /**
* \brief This callback is called when the connection is about to upgrade to * \brief This callback is called when the connection is about to upgrade to
* TLS. * TLS.

View file

@ -344,13 +344,26 @@
exception: (OFException*)exception exception: (OFException*)exception
{ {
if (exception != nil) { if (exception != nil) {
[delegates broadcastSelector: @selector(connection:
didThrowException::)
withObject: self
withObject: exception];
[self close]; [self close];
return NO; return NO;
} }
@try {
if (![self XMPP_parseBuffer: buffer if (![self XMPP_parseBuffer: buffer
length: length]) length: length])
return NO; return NO;
} @catch (id e) {
[delegates broadcastSelector: @selector(connection:
didThrowException::)
withObject: self
withObject: e];
[self close];
return NO;
}
if (oldParser != nil || oldElementBuilder != nil) { if (oldParser != nil || oldElementBuilder != nil) {
[oldParser release]; [oldParser release];