Better handling of remote stream close

This commit is contained in:
Florian Zeitz 2012-01-25 01:12:42 +01:00
parent f6bfef0615
commit 4efd9d8881

View file

@ -269,12 +269,11 @@
size_t length = [sock readNBytes: 512 size_t length = [sock readNBytes: 512
intoBuffer: buffer]; intoBuffer: buffer];
if (length < 1 && [delegate respondsToSelector: [self parseBuffer: buffer
@selector(connectionWasClosed:)]) withLength: length];
[delegate connectionWasClosed: self];
[parser parseBuffer: buffer if (length < 1)
withLength: length]; return;
} }
} }
@ -282,8 +281,10 @@
withLength: (size_t)length withLength: (size_t)length
{ {
if (length < 1 && [delegate respondsToSelector: if (length < 1 && [delegate respondsToSelector:
@selector(connectionWasClosed:)]) @selector(connectionWasClosed:)]) {
[delegate connectionWasClosed: self]; [delegate connectionWasClosed: self];
return;
}
[parser parseBuffer: buffer [parser parseBuffer: buffer
withLength: length]; withLength: length];
@ -454,6 +455,19 @@ withCallbackBlock: (xmpp_callback_block)callback;
[self XMPP_handleSASL: element]; [self XMPP_handleSASL: element];
} }
- (void)elementBuilder: (OFXMLElementBuilder *)builder
didNotExpectCloseTag: (OFString *)name
withPrefix: (OFString *)prefix
namespace: (OFString *)ns
{
if (![name isEqual: @"stream"] || ![prefix isEqual: @"stream"] ||
![ns isEqual: XMPP_NS_STREAM]) {
@throw [OFMalformedXMLException
exceptionWithClass: [builder class]
parser: nil];
}
}
- (void)XMPP_startStream - (void)XMPP_startStream
{ {
/* Make sure we don't get any old events */ /* Make sure we don't get any old events */