XMPPProcessOne.h
3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
109
110
111
112
113
114
115
116
117
#import <Foundation/Foundation.h>
#import "XMPPSASLAuthentication.h"
#import "XMPPStream.h"
#import "XMPPModule.h"
@class XMPPRebindAuthentication;
/**
* Process One has a proprietary module they sell for ejabberd that enables several
* features such as push notifications and fast reconnect.
*
* This file implements the client side functionality for XMPPFramework.
**/
@interface XMPPProcessOne : XMPPModule
/**
* Once a connection is authenticated, the module automatically stores the session ID and related JID.
* The information is stored in the user defaults system, thus it is persisted across launches of the application.
*
* If the session information is available, and the server supports rebind, fast reconnect may be possible.
**/
@property (strong, readwrite) NSString *savedSessionID;
@property (strong, readwrite) XMPPJID *savedSessionJID;
@property (strong, readwrite) NSDate *savedSessionDate;
/**
* Push Mode Configuration.
* Options are detailed in the documentation from ejabberd.
*
* An example of a pushConfiguration element you would set:
*
* <push xmlns='p1:push'>
* <keepalive max='30'/>
* <session duration='60'/>
* <body send='all' groupchat='true' from='jid'/>
* <status type='xa'>Text Message when in push mode</status>
* <offline>false</offline>
* <notification>
* <type>applepush</type>
* <id>DeviceToken</id>
* </notification>
* <appid>application1</appid>
* </push>
*
* To enable Apple Push on the ejabberd server, you must set the pushConfiguration element.
*
* You may set the pushConfiguration element at any time.
* If you set it after the xmpp stream has already authenticated, then the push settings will be sent right away.
* Otherwise, the push settings will be sent as soon as the stream is authenticated.
*
* After the pushConfiguration element has been set, you can change it at any time.
* If you do, it will send the updated configuration options to the server.
*
* To disable push, you can simply set the pushConfiguration to nil.
*
* @see pushConfigurationContainer
**/
@property (readwrite, strong) NSXMLElement *pushConfiguration;
/**
* Standby Mode.
* The following methods allow you to switch on/off standby mode.
*
* Typical use case looks like this:
*
* - (void)applicationWillResignActive:(NSNotification *)notification
* {
* // Send standby element (via normal asynchronous mechanism)
* XMPPElementReceipt *receipt = [xmppProcessOne goOnStandby];
*
* // Wait until standby element gets sent (pumped through dispatch queues and into OS socket buffer)
* [receipt wait:-1.0];
* }
*
* - (void)applicationDidBecomeActive:(NSNotification *)notification
* {
* [xmppProcessOne goOffStandby];
* }
**/
- (XMPPElementReceipt *)goOnStandby;
- (XMPPElementReceipt *)goOffStandby;
/**
* Methods to help create the pushConfiguration required to enable anything on the server.
**/
+ (NSXMLElement *)pushConfigurationContainer;
+ (NSXMLElement *)keepaliveWithMax:(NSTimeInterval)max;
+ (NSXMLElement *)sessionWithDuration:(NSTimeInterval)duration;
+ (NSXMLElement *)statusWithType:(NSString *)type message:(NSString *)message;
@end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@interface XMPPRebindAuthentication : NSObject <XMPPSASLAuthentication>
- (id)initWithStream:(XMPPStream *)stream sessionID:(NSString *)sessionID sessionJID:(XMPPJID *)sessionJID;
@end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@interface XMPPStream (XMPPProcessOne)
- (BOOL)supportsPush;
- (BOOL)supportsRebind;
- (NSString *)rebindSessionID;
@end