File tree Expand file tree Collapse file tree 2 files changed +35
-13
lines changed Expand file tree Collapse file tree 2 files changed +35
-13
lines changed Original file line number Diff line number Diff line change 1
1
github "robbiehanson/CocoaAsyncSocket" "562bae6af6dbd7e1891293dae20b9f79a2fd7228"
2
2
github "Mantle/Mantle" "a16d18f635b3ba1ffb01d27d4393ee97cadf4f34"
3
- github "rabbitmq/rabbitmq-objc-client" "ea25de2d8d43152f8040d0994a9a3a4239d9442f "
3
+ github "rabbitmq/rabbitmq-objc-client" "de0f201af7d3fd94f62ef29568c83ab88b2b35fb "
Original file line number Diff line number Diff line change 1
- //
2
- // ViewController.m
3
- // tutorial3
4
- //
5
- // Created by Pivotal on 25/04/2016.
6
- // Copyright © 2016 RabbitMQ. All rights reserved.
7
- //
8
-
9
1
#import " ViewController.h"
10
2
@import RMQClient;
11
3
@@ -17,12 +9,42 @@ @implementation ViewController
17
9
18
10
- (void )viewDidLoad {
19
11
[super viewDidLoad ];
20
- // Do any additional setup after loading the view, typically from a nib.
12
+ [self receiveLogs ];
13
+ [self receiveLogs ];
14
+ sleep (1 );
15
+ [self emitLog ];
21
16
}
22
17
23
- - (void )didReceiveMemoryWarning {
24
- [super didReceiveMemoryWarning ];
25
- // Dispose of any resources that can be recreated.
18
+ - (void )emitLog {
19
+ RMQConnection *conn = [[RMQConnection alloc ] initWithDelegate: [RMQConnectionDelegateLogger new ]];
20
+ [conn start ];
21
+
22
+ id <RMQChannel> ch = [conn createChannel ];
23
+ RMQExchange *x = [ch fanout: @" logs" options: RMQExchangeDeclareNoOptions];
24
+
25
+ NSString *msg = @" Hello World!" ;
26
+
27
+ [x publish: msg];
28
+ NSLog (@" Sent %@ " , msg);
29
+
30
+ [conn close ];
31
+ }
32
+
33
+ - (void )receiveLogs {
34
+ RMQConnection *conn = [[RMQConnection alloc ] initWithDelegate: [RMQConnectionDelegateLogger new ]];
35
+ [conn start ];
36
+
37
+ id <RMQChannel> ch = [conn createChannel ];
38
+ RMQExchange *x = [ch fanout: @" logs" options: RMQExchangeDeclareNoOptions];
39
+ RMQQueue *q = [ch queue: @" " options: RMQQueueDeclareExclusive];
40
+
41
+ [q bind: x];
42
+
43
+ NSLog (@" Waiting for logs." );
44
+
45
+ [q subscribe: ^(RMQMessage * _Nonnull message) {
46
+ NSLog (@" Received %@ " , message);
47
+ }];
26
48
}
27
49
28
50
@end
You can’t perform that action at this time.
0 commit comments