1
2
3
4
5
6
7
8
9
10
|
1
2
3
4
5
6
7
8
9
10
|
-
+
|
/*
* Copyright (c) 2012, Florian Zeitz <florob@babelmonkeys.de>
* Copyright (c) 2019, Jonathan Schleifer <js@heap.zone>
* Copyright (c) 2019, 2021, Jonathan Schleifer <js@nil.im>
*
* https://heap.zone/objxmpp/
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
-
+
-
+
-
+
-
+
-
-
+
|
- (void)connection: (XMPPConnection *)connection
didReceiveElement: (OFXMLElement *)element
{
OFString *elementName = element.name;
OFString *elementNS = element.namespace;
if ([elementNS isEqual: XMPP_NS_SM]) {
if ([elementNS isEqual: XMPPSMNS]) {
if ([elementName isEqual: @"enabled"]) {
_receivedCount = 0;
return;
}
if ([elementName isEqual: @"failed"]) {
/* TODO: How do we handle this? */
return;
}
if ([elementName isEqual: @"r"]) {
OFXMLElement *ack =
[OFXMLElement elementWithName: @"a"
namespace: XMPP_NS_SM];
namespace: XMPPSMNS];
OFString *stringValue = [OFString
stringWithFormat: @"%" PRIu32, _receivedCount];
[ack addAttributeWithName: @"h"
stringValue: stringValue];
[connection sendStanza: ack];
}
}
if ([elementNS isEqual: XMPP_NS_CLIENT] &&
if ([elementNS isEqual: XMPPClientNS] &&
([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
- (void)connection: (XMPPConnection *)connection wasBoundToJID: (XMPPJID *)JID
wasBoundToJID: (XMPPJID *)JID
{
if (connection.supportsStreamManagement)
[connection sendStanza:
[OFXMLElement elementWithName: @"enable"
namespace: XMPP_NS_SM]];
namespace: XMPPSMNS]];
}
@end
|