22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
+
+
+
+
+
-
+
|
#include <inttypes.h>
#import "XMPPStreamManagement.h"
#import "namespaces.h"
@implementation XMPPStreamManagement
- init
{
OF_INVALID_INIT_METHOD
}
- initWithConnection: (XMPPConnection*)connection
- initWithConnection: (XMPPConnection *)connection
{
self = [super init];
@try {
_connection = connection;
[_connection addDelegate: self];
} @catch (id e) {
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
-
-
+
+
|
- (void)dealloc
{
[_connection removeDelegate: self];
[super dealloc];
}
- (void)connection: (XMPPConnection*)connection
didReceiveElement: (OFXMLElement*)element
- (void)connection: (XMPPConnection *)connection
didReceiveElement: (OFXMLElement *)element
{
OFString *elementName = [element name];
OFString *elementNS = [element namespace];
if ([elementNS isEqual: XMPP_NS_SM]) {
if ([elementName isEqual: @"enabled"]) {
_receivedCount = 0;
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
-
-
+
+
-
-
+
+
|
([elementName isEqual: @"iq"] ||
[elementName isEqual: @"presence"] ||
[elementName isEqual: @"message"]))
_receivedCount++;
}
/* TODO: Count outgoing stanzas here and cache them, send own ACK requests
- (void)connection: (XMPPConnection*)connection
didSendElement: (OFXMLElement*)element
- (void)connection: (XMPPConnection *)connection
didSendElement: (OFXMLElement *)element
{
}
*/
- (void)connection: (XMPPConnection*)connection
wasBoundToJID: (XMPPJID*)JID
- (void)connection: (XMPPConnection *)connection
wasBoundToJID: (XMPPJID *)JID
{
if ([connection supportsStreamManagement])
[connection sendStanza:
[OFXMLElement elementWithName: @"enable"
namespace: XMPP_NS_SM]];
}
@end
|