This repository has been archived by the owner on Dec 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
CRVStompClient.h
87 lines (74 loc) · 2.78 KB
/
CRVStompClient.h
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
//
// CRVStompClient.h
// Objc-Stomp
//
//
// Implements the Stomp Protocol v1.0
// See: http://stomp.codehaus.org/Protocol
//
// Requires the AsyncSocket library
// See: http://code.google.com/p/cocoaasyncsocket/
//
// See: LICENSE
// Stefan Saasen <[email protected]>
// Based on StompService.{h,m} by Scott Raymond <[email protected]>.
#import <Foundation/Foundation.h>
#import "AsyncSocket.h"
@class CRVStompClient;
typedef enum {
CRVStompAckModeAuto,
CRVStompAckModeClient
} CRVStompAckMode;
@protocol CRVStompClientDelegate <NSObject>
- (void)stompClient:(CRVStompClient *)stompService messageReceived:(NSString *)body withHeader:(NSDictionary *)messageHeader;
@optional
- (void)stompClientDidDisconnect:(CRVStompClient *)stompService;
- (void)stompClientWillDisconnect:(CRVStompClient *)stompService withError:(NSError*)error;
- (void)stompClientDidConnect:(CRVStompClient *)stompService;
- (void)serverDidSendReceipt:(CRVStompClient *)stompService withReceiptId:(NSString *)receiptId;
- (void)serverDidSendError:(CRVStompClient *)stompService withErrorMessage:(NSString *)description detailedErrorMessage:(NSString *) theMessage;
@end
@interface CRVStompClient : NSObject {
@private
id<CRVStompClientDelegate> delegate;
AsyncSocket *socket;
NSString *host;
NSUInteger port;
NSString *login;
NSString *passcode;
NSString *sessionId;
BOOL doAutoconnect;
BOOL anonymous;
}
@property (nonatomic, assign) id<CRVStompClientDelegate> delegate;
- (id)initWithHost:(NSString *)theHost
port:(NSUInteger)thePort
login:(NSString *)theLogin
passcode:(NSString *)thePasscode
delegate:(id<CRVStompClientDelegate>)theDelegate;
- (id)initWithHost:(NSString *)theHost
port:(NSUInteger)thePort
login:(NSString *)theLogin
passcode:(NSString *)thePasscode
delegate:(id<CRVStompClientDelegate>)theDelegate
autoconnect:(BOOL) autoconnect;
/**
* Connects as an anonymous user. Suppresses "login" and "passcode" headers.
*/
- (id)initWithHost:(NSString *)theHost
port:(NSUInteger)thePort
delegate:(id<CRVStompClientDelegate>)theDelegate
autoconnect:(BOOL) autoconnect;
- (void)connect;
- (void)sendMessage:(NSString *)theMessage toDestination:(NSString *)destination;
- (void)sendMessage:(NSString *)theMessage toDestination:(NSString *)destination withHeaders:(NSDictionary*)headers;
- (void)subscribeToDestination:(NSString *)destination;
- (void)subscribeToDestination:(NSString *)destination withAck:(CRVStompAckMode) ackMode;
- (void)subscribeToDestination:(NSString *)destination withHeader:(NSDictionary *) header;
- (void)unsubscribeFromDestination:(NSString *)destination;
- (void)begin:(NSString *)transactionId;
- (void)commit:(NSString *)transactionId;
- (void)abort:(NSString *)transactionId;
- (void)ack:(NSString *)messageId;
- (void)disconnect;
@end