|
7 | 7 | //
|
8 | 8 |
|
9 | 9 | #import "RCTMqtt.h"
|
10 |
| -#import "RCTBridgeModule.h" |
11 |
| -#import "RCTLog.h" |
12 |
| -#import "RCTUtils.h" |
13 |
| -#import "RCTEventDispatcher.h" |
| 10 | +#import <React/RCTBridgeModule.h> |
| 11 | +#import <React/RCTLog.h> |
| 12 | +#import <React/RCTUtils.h> |
| 13 | +#import <React/RCTEventDispatcher.h> |
14 | 14 |
|
15 | 15 | #import <MQTTClient/MQTTClient.h>
|
16 | 16 | #import <MQTTClient/MQTTSessionManager.h>
|
@@ -85,37 +85,32 @@ - (void)appDidBecomeActive {
|
85 | 85 | resolve([NSNumber numberWithInt:clientRef]);
|
86 | 86 |
|
87 | 87 | }
|
88 |
| - |
89 |
| -RCT_EXPORT_METHOD(removeClient:(int) clientRef |
90 |
| - resolver:(RCTPromiseResolveBlock)resolve |
91 |
| - rejecter:(RCTPromiseRejectBlock)reject) { |
| 88 | +RCT_EXPORT_METHOD(connect:(int) clientRef) { |
92 | 89 |
|
93 |
| - [[self clients] removeObjectForKey:[NSNumber numberWithInt:clientRef]]; |
94 |
| - resolve([NSNumber numberWithInt:clientRef]); |
| 90 | + [[[self clients] objectForKey:[NSNumber numberWithInt:clientRef]] connect]; |
95 | 91 |
|
96 | 92 | }
|
97 | 93 |
|
98 |
| -RCT_EXPORT_METHOD(connect:(nonnull NSNumber *) clientRef) { |
99 |
| - |
100 |
| - [[[self clients] objectForKey:clientRef] connect]; |
101 |
| - |
102 |
| -} |
103 | 94 |
|
| 95 | +RCT_EXPORT_METHOD(disconnect:(int) clientRef) { |
| 96 | + [[[self clients] objectForKey:[NSNumber numberWithInt:clientRef]] disconnect]; |
| 97 | +} |
104 | 98 |
|
105 |
| -RCT_EXPORT_METHOD(disconnect:(nonnull NSNumber *) clientRef) { |
106 |
| - [[[self clients] objectForKey:clientRef] disconnect]; |
| 99 | +RCT_EXPORT_METHOD(subscribe:(int) clientRef topic:(NSString *)topic qos:(int)qos) { |
| 100 | + [[[self clients] objectForKey:[NSNumber numberWithInt:clientRef]] subscribe:topic qos:[NSNumber numberWithInt:qos]]; |
| 101 | + |
107 | 102 | }
|
108 | 103 |
|
109 |
| -RCT_EXPORT_METHOD(subscribe:(nonnull NSNumber *) clientRef topic:(NSString *)topic qos:(nonnull NSNumber *)qos) { |
110 |
| - [[[self clients] objectForKey:clientRef] subscribe:topic qos:qos]]; |
| 104 | +RCT_EXPORT_METHOD(unsubscribe:(int) clientRef topic:(NSString *)topic) { |
| 105 | + [[[self clients] objectForKey:[NSNumber numberWithInt:clientRef]] unsubscribe:topic]; |
111 | 106 |
|
112 | 107 | }
|
113 | 108 |
|
114 |
| -RCT_EXPORT_METHOD(publish:(nonnull NSNumber *) clientRef topic:(NSString *)topic data:(NSString*)data qos:(nonnull NSNumber *)qos retain:(BOOL)retain) { |
115 |
| - [[[self clients] objectForKey:clientRef] publish:topic |
116 |
| - data:[data dataUsingEncoding:NSUTF8StringEncoding] |
117 |
| - qos:qos |
118 |
| - retain:retain]; |
| 109 | +RCT_EXPORT_METHOD(publish:(int) clientRef topic:(NSString *)topic data:(NSString*)data qos:(int)qos retain:(int)retain) { |
| 110 | + [[[self clients] objectForKey:[NSNumber numberWithInt:clientRef]] publish:topic |
| 111 | + data:[data dataUsingEncoding:NSUTF8StringEncoding] |
| 112 | + qos:[NSNumber numberWithInt:qos] |
| 113 | + retain:(BOOL)retain]; |
119 | 114 |
|
120 | 115 | }
|
121 | 116 |
|
|
0 commit comments