ObjXMPP  Check-in [24bab36d7d]

Overview
Comment:Better handling of remote stream close
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 24bab36d7ddeed4c9364a81c3869fcfd973acbf0a336bba1f28118249b510aed
User & Date: florob@babelmonkeys.de on 2012-01-25 00:12:42
Other Links: manifest | tags
Context
2012-01-25
12:18
Add -close method check-in: d876014b9d user: florob@babelmonkeys.de tags: trunk
00:12
Better handling of remote stream close check-in: 24bab36d7d user: florob@babelmonkeys.de tags: trunk
2012-01-16
22:33
Add missing messages check-in: 3a806e9e04 user: florob@babelmonkeys.de tags: trunk
Changes

Modified src/XMPPConnection.m from [3fea282f95] to [edad7fe838].

265
266
267
268
269
270
271
272
273
274
275
276
277



278
279
280
281
282
283
284
285
286


287
288
289
290
291
292
293
{
	char buffer[512];

	for (;;) {
		size_t length = [sock readNBytes: 512
				      intoBuffer: buffer];

		if (length < 1 && [delegate respondsToSelector:
		    @selector(connectionWasClosed:)])
			[delegate connectionWasClosed: self];

		[parser parseBuffer: buffer
			 withLength: length];



	}
}

- (void)parseBuffer: (const char*)buffer
	 withLength: (size_t)length
{
	if (length < 1 && [delegate respondsToSelector:
	    @selector(connectionWasClosed:)])
		[delegate connectionWasClosed: self];



	[parser parseBuffer: buffer
		 withLength: length];

	[oldParser release];
	[oldElementBuilder release];








<
<
<
<
|
|
>
>
>







|

>
>







265
266
267
268
269
270
271




272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
{
	char buffer[512];

	for (;;) {
		size_t length = [sock readNBytes: 512
				      intoBuffer: buffer];





		[self parseBuffer: buffer
		       withLength: length];

		if (length < 1)
			return;
	}
}

- (void)parseBuffer: (const char*)buffer
	 withLength: (size_t)length
{
	if (length < 1 && [delegate respondsToSelector:
	    @selector(connectionWasClosed:)]) {
		[delegate connectionWasClosed: self];
		return;
	}

	[parser parseBuffer: buffer
		 withLength: length];

	[oldParser release];
	[oldElementBuilder release];

449
450
451
452
453
454
455













456
457
458
459
460
461
462

	if ([[element namespace] isEqual: XMPP_NS_STARTTLS])
		[self XMPP_handleTLS: element];

	if ([[element namespace] isEqual: XMPP_NS_SASL])
		[self XMPP_handleSASL: element];
}














- (void)XMPP_startStream
{
	/* Make sure we don't get any old events */
	[parser setDelegate: nil];
	[elementBuilder setDelegate: nil];








>
>
>
>
>
>
>
>
>
>
>
>
>







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476

	if ([[element namespace] isEqual: XMPP_NS_STARTTLS])
		[self XMPP_handleTLS: element];

	if ([[element namespace] isEqual: XMPP_NS_SASL])
		[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
{
	/* Make sure we don't get any old events */
	[parser setDelegate: nil];
	[elementBuilder setDelegate: nil];