Differences From Artifact [934072be7a]:
- File
src/XMPPConnection.m
— part of check-in
[a618f77f45]
at
2012-08-10 12:08:23
on branch trunk
— Add very basic Stream Management (XEP-0198) support
This implementation only counts incomming stanzas and
sends ACKs on request.
While basic this already allows servers to write
messages to offline storage that were sent to,
but never received by a client. (user: js, size: 26853) [annotate] [blame] [check-ins using]
To Artifact [efe09bc35c]:
- File src/XMPPConnection.m — part of check-in [71cf6454e4] at 2012-09-20 00:35:14 on branch trunk — Handle the connection in the run loop. (user: js, size: 27600) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #import "XMPPPresence.h" #import "XMPPMulticastDelegate.h" #import "XMPPExceptions.h" #import "XMPPXMLElementBuilder.h" #import "namespaces.h" #import <ObjFW/macros.h> @implementation XMPPConnection + connection { return [[[self alloc] init] autorelease]; } | > > | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #import "XMPPPresence.h" #import "XMPPMulticastDelegate.h" #import "XMPPExceptions.h" #import "XMPPXMLElementBuilder.h" #import "namespaces.h" #import <ObjFW/macros.h> #define BUFFER_LENGTH 512 @implementation XMPPConnection + connection { return [[[self alloc] init] autorelease]; } |
︙ | ︙ | |||
288 289 290 291 292 293 294 | [self XMPP_startStream]; [pool release]; } - (void)handleConnection { | | < | | | < < | < < | | < | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | [self XMPP_startStream]; [pool release]; } - (void)handleConnection { char *buffer = [self allocMemoryWithSize: BUFFER_LENGTH]; [sock asyncReadIntoBuffer: buffer length: BUFFER_LENGTH target: self selector: @selector(stream:didReadIntoBuffer:length:)]; } - (BOOL)XMPP_parseBuffer: (const void*)buffer length: (size_t)length { if ([sock isAtEndOfStream]) { [delegates broadcastSelector: @selector(connectionWasClosed:) withObject: self]; return NO; } @try { [parser parseBuffer: buffer length: length]; } @catch (OFMalformedXMLException *e) { [self XMPP_sendStreamError: @"bad-format" text: nil]; [self close]; return NO; } return YES; } - (void)parseBuffer: (const void*)buffer length: (size_t)length { [self XMPP_parseBuffer: buffer length: length]; [oldParser release]; [oldElementBuilder release]; oldParser = nil; oldElementBuilder = nil; } - (BOOL)stream: (OFStream*)stream didReadIntoBuffer: (char*)buffer length: (size_t)length { if (![self XMPP_parseBuffer: buffer length: length]) return NO; if (oldParser != nil || oldElementBuilder != nil) { [oldParser release]; [oldElementBuilder release]; oldParser = nil; oldElementBuilder = nil; [sock asyncReadIntoBuffer: buffer length: BUFFER_LENGTH target: self selector: @selector(stream: didReadIntoBuffer:length:)]; return NO; } return YES; } - (OFTCPSocket*)socket { return [[sock retain] autorelease]; } - (BOOL)encryptionRequired |
︙ | ︙ |