├── .gitignore ├── README.md ├── android ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── tuanpm │ └── RCTMqtt │ ├── RCTMqtt.java │ ├── RCTMqttModule.java │ └── RCTMqttPackage.java ├── index.js ├── ios └── RCTMqtt │ ├── Mqtt.h │ ├── Mqtt.m │ ├── Podfile │ ├── Podfile.lock │ ├── Pods │ ├── CocoaLumberjack │ │ ├── Classes │ │ │ ├── CocoaLumberjack.h │ │ │ ├── CocoaLumberjack.swift │ │ │ ├── DDASLLogCapture.h │ │ │ ├── DDASLLogCapture.m │ │ │ ├── DDASLLogger.h │ │ │ ├── DDASLLogger.m │ │ │ ├── DDAbstractDatabaseLogger.h │ │ │ ├── DDAbstractDatabaseLogger.m │ │ │ ├── DDAssertMacros.h │ │ │ ├── DDFileLogger.h │ │ │ ├── DDFileLogger.m │ │ │ ├── DDLegacyMacros.h │ │ │ ├── DDLog+LOGV.h │ │ │ ├── DDLog.h │ │ │ ├── DDLog.m │ │ │ ├── DDLogMacros.h │ │ │ ├── DDTTYLogger.h │ │ │ ├── DDTTYLogger.m │ │ │ └── Extensions │ │ │ │ ├── DDContextFilterLogFormatter.h │ │ │ │ ├── DDContextFilterLogFormatter.m │ │ │ │ ├── DDDispatchQueueLogFormatter.h │ │ │ │ ├── DDDispatchQueueLogFormatter.m │ │ │ │ ├── DDMultiFormatter.h │ │ │ │ └── DDMultiFormatter.m │ │ ├── Framework │ │ │ └── Lumberjack │ │ │ │ └── CocoaLumberjack.modulemap │ │ ├── LICENSE.txt │ │ └── README.md │ ├── Headers │ │ ├── Private │ │ │ ├── CocoaLumberjack │ │ │ │ ├── CocoaLumberjack.h │ │ │ │ ├── DDASLLogCapture.h │ │ │ │ ├── DDASLLogger.h │ │ │ │ ├── DDAbstractDatabaseLogger.h │ │ │ │ ├── DDAssertMacros.h │ │ │ │ ├── DDContextFilterLogFormatter.h │ │ │ │ ├── DDDispatchQueueLogFormatter.h │ │ │ │ ├── DDFileLogger.h │ │ │ │ ├── DDLegacyMacros.h │ │ │ │ ├── DDLog+LOGV.h │ │ │ │ ├── DDLog.h │ │ │ │ ├── DDLogMacros.h │ │ │ │ ├── DDMultiFormatter.h │ │ │ │ └── DDTTYLogger.h │ │ │ ├── MQTTClient │ │ │ │ ├── MQTTCFSocketDecoder.h │ │ │ │ ├── MQTTCFSocketEncoder.h │ │ │ │ ├── MQTTCFSocketTransport.h │ │ │ │ ├── MQTTClient.h │ │ │ │ ├── MQTTCoreDataPersistence.h │ │ │ │ ├── MQTTDecoder.h │ │ │ │ ├── MQTTInMemoryPersistence.h │ │ │ │ ├── MQTTLog.h │ │ │ │ ├── MQTTMessage.h │ │ │ │ ├── MQTTPersistence.h │ │ │ │ ├── MQTTSSLSecurityPolicy.h │ │ │ │ ├── MQTTSSLSecurityPolicyDecoder.h │ │ │ │ ├── MQTTSSLSecurityPolicyEncoder.h │ │ │ │ ├── MQTTSSLSecurityPolicyTransport.h │ │ │ │ ├── MQTTSession.h │ │ │ │ ├── MQTTSessionLegacy.h │ │ │ │ ├── MQTTSessionManager.h │ │ │ │ ├── MQTTSessionSynchron.h │ │ │ │ ├── MQTTTransport.h │ │ │ │ └── MQTTWebsocketTransport.h │ │ │ └── SocketRocket │ │ │ │ └── SRWebSocket.h │ │ └── Public │ │ │ ├── CocoaLumberjack │ │ │ ├── CocoaLumberjack.h │ │ │ ├── DDASLLogCapture.h │ │ │ ├── DDASLLogger.h │ │ │ ├── DDAbstractDatabaseLogger.h │ │ │ ├── DDAssertMacros.h │ │ │ ├── DDContextFilterLogFormatter.h │ │ │ ├── DDDispatchQueueLogFormatter.h │ │ │ ├── DDFileLogger.h │ │ │ ├── DDLegacyMacros.h │ │ │ ├── DDLog+LOGV.h │ │ │ ├── DDLog.h │ │ │ ├── DDLogMacros.h │ │ │ ├── DDMultiFormatter.h │ │ │ └── DDTTYLogger.h │ │ │ ├── MQTTClient │ │ │ ├── MQTTCFSocketDecoder.h │ │ │ ├── MQTTCFSocketEncoder.h │ │ │ ├── MQTTCFSocketTransport.h │ │ │ ├── MQTTClient.h │ │ │ ├── MQTTCoreDataPersistence.h │ │ │ ├── MQTTDecoder.h │ │ │ ├── MQTTInMemoryPersistence.h │ │ │ ├── MQTTLog.h │ │ │ ├── MQTTMessage.h │ │ │ ├── MQTTPersistence.h │ │ │ ├── MQTTSSLSecurityPolicy.h │ │ │ ├── MQTTSSLSecurityPolicyDecoder.h │ │ │ ├── MQTTSSLSecurityPolicyEncoder.h │ │ │ ├── MQTTSSLSecurityPolicyTransport.h │ │ │ ├── MQTTSession.h │ │ │ ├── MQTTSessionLegacy.h │ │ │ ├── MQTTSessionManager.h │ │ │ ├── MQTTSessionSynchron.h │ │ │ ├── MQTTTransport.h │ │ │ └── MQTTWebsocketTransport.h │ │ │ └── SocketRocket │ │ │ └── SRWebSocket.h │ ├── MQTTClient │ │ ├── LICENSE │ │ ├── MQTTClient │ │ │ └── MQTTClient │ │ │ │ ├── MQTTCFSocketDecoder.h │ │ │ │ ├── MQTTCFSocketDecoder.m │ │ │ │ ├── MQTTCFSocketEncoder.h │ │ │ │ ├── MQTTCFSocketEncoder.m │ │ │ │ ├── MQTTCFSocketTransport.h │ │ │ │ ├── MQTTCFSocketTransport.m │ │ │ │ ├── MQTTClient.h │ │ │ │ ├── MQTTCoreDataPersistence.h │ │ │ │ ├── MQTTCoreDataPersistence.m │ │ │ │ ├── MQTTDecoder.h │ │ │ │ ├── MQTTDecoder.m │ │ │ │ ├── MQTTInMemoryPersistence.h │ │ │ │ ├── MQTTInMemoryPersistence.m │ │ │ │ ├── MQTTLog.h │ │ │ │ ├── MQTTMessage.h │ │ │ │ ├── MQTTMessage.m │ │ │ │ ├── MQTTPersistence.h │ │ │ │ ├── MQTTSSLSecurityPolicy.h │ │ │ │ ├── MQTTSSLSecurityPolicy.m │ │ │ │ ├── MQTTSSLSecurityPolicyDecoder.h │ │ │ │ ├── MQTTSSLSecurityPolicyDecoder.m │ │ │ │ ├── MQTTSSLSecurityPolicyEncoder.h │ │ │ │ ├── MQTTSSLSecurityPolicyEncoder.m │ │ │ │ ├── MQTTSSLSecurityPolicyTransport.h │ │ │ │ ├── MQTTSSLSecurityPolicyTransport.m │ │ │ │ ├── MQTTSession.h │ │ │ │ ├── MQTTSession.m │ │ │ │ ├── MQTTSessionLegacy.h │ │ │ │ ├── MQTTSessionLegacy.m │ │ │ │ ├── MQTTSessionManager.h │ │ │ │ ├── MQTTSessionManager.m │ │ │ │ ├── MQTTSessionSynchron.h │ │ │ │ ├── MQTTSessionSynchron.m │ │ │ │ ├── MQTTTransport.h │ │ │ │ ├── MQTTTransport.m │ │ │ │ └── MQTTWebsocketTransport │ │ │ │ ├── MQTTWebsocketTransport.h │ │ │ │ └── MQTTWebsocketTransport.m │ │ └── README.md │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ ├── SocketRocket │ │ ├── LICENSE │ │ ├── README.rst │ │ └── SocketRocket │ │ │ ├── SRWebSocket.h │ │ │ └── SRWebSocket.m │ └── Target Support Files │ │ ├── CocoaLumberjack │ │ ├── CocoaLumberjack-dummy.m │ │ ├── CocoaLumberjack-prefix.pch │ │ └── CocoaLumberjack.xcconfig │ │ ├── MQTTClient │ │ ├── MQTTClient-dummy.m │ │ ├── MQTTClient-prefix.pch │ │ └── MQTTClient.xcconfig │ │ ├── Pods-RCTMqtt │ │ ├── Pods-RCTMqtt-acknowledgements.markdown │ │ ├── Pods-RCTMqtt-acknowledgements.plist │ │ ├── Pods-RCTMqtt-dummy.m │ │ ├── Pods-RCTMqtt-frameworks.sh │ │ ├── Pods-RCTMqtt-resources.sh │ │ ├── Pods-RCTMqtt.debug.xcconfig │ │ └── Pods-RCTMqtt.release.xcconfig │ │ ├── Pods │ │ ├── Pods-acknowledgements.markdown │ │ ├── Pods-acknowledgements.plist │ │ ├── Pods-dummy.m │ │ ├── Pods-frameworks.sh │ │ ├── Pods-resources.sh │ │ ├── Pods.debug.xcconfig │ │ └── Pods.release.xcconfig │ │ └── SocketRocket │ │ ├── SocketRocket-dummy.m │ │ ├── SocketRocket-prefix.pch │ │ └── SocketRocket.xcconfig │ ├── RCTMqtt.h │ ├── RCTMqtt.m │ ├── RCTMqtt.xcodeproj │ └── project.pbxproj │ └── RCTMqtt.xcworkspace │ └── contents.xcworkspacedata └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IJ 26 | # 27 | .idea 28 | .gradle 29 | local.properties 30 | 31 | # node.js 32 | # 33 | node_modules/ 34 | npm-debug.log 35 | 36 | #CocoaPods 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [![npm](https://img.shields.io/npm/dt/react-native-mqtt.svg)]() 4 | 5 | # Please use [paho.mqtt.javascript](https://github.com/eclipse/paho.mqtt.javascript) for your application, this repository not use for production 6 | 7 | ## Description 8 | 9 | [react-native](https://github.com/facebook/react-native) mqtt client module 10 | 11 | ## MQTT Features (inherit from native MQTT framework) 12 | * Use [MQTT Framework](https://github.com/ckrey/MQTT-Client-Framework) for IOS, [Paho MQTT Client](https://eclipse.org/paho/clients/android/) for Android 13 | * Support both IOS and Android 14 | * SSL/TLS 15 | * Native library, support mqtt over tcp 16 | 17 | ## Warning 18 | This library in progress developing, api may change, SSL/TLS non verify 19 | 20 | ## Getting started 21 | 22 | ### Manual install 23 | #### iOS 24 | - `npm install react-native-mqtt@latest --save` 25 | - In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` 26 | - Go to `node_modules` ➜ `react-native-mqtt` and add `RCTMqtt.xcodeproj` 27 | - In XCode, in the project navigator, select your project. Add `libRCTmqtt.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` 28 | - Click `RCTMqtt.xcodeproj` in the project navigator and go the `Build Settings` tab. Make sure 'All' is toggled on (instead of 'Basic'). In the `Search Paths` section, look for `Header Search Paths` and make sure it contains both `$(SRCROOT)/../../react-native/React` - mark as `recursive`. 29 | - Run your project (`Cmd+R`) 30 | 31 | 32 | #### Android 33 | 34 | - `npm install react-native-mqtt@latest --save` 35 | - Modify the ReactInstanceManager.builder() calls chain in `android/app/main/java/.../MainActivity.java` to include: 36 | 37 | ```javascript 38 | import com.tuanpm.RCTMqtt.*; // import 39 | 40 | 41 | .addPackage(new RCTMqttPackage()) //for older version 42 | 43 | new RCTMqttPackage() // for newest version of react-native 44 | ``` 45 | 46 | - Append the following lines to `android/settings.gradle` before `include ':app'`: 47 | 48 | ``` 49 | include ':react-native-mqtt' 50 | project(':react-native-mqtt').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mqtt/android') 51 | 52 | ``` 53 | 54 | 55 | - Insert the following lines inside the dependencies block in `android/app/build.gradle`, don't missing `apply plugin:'java'` on top: 56 | 57 | ``` 58 | compile project(':react-native-mqtt') 59 | ``` 60 | 61 | Notes: 62 | 63 | ``` 64 | dependencies { 65 | compile project(':react-native-mqtt') 66 | } 67 | ``` 68 | 69 | 70 | ## Usage 71 | 72 | ```javascript 73 | var mqtt = require('react-native-mqtt'); 74 | 75 | /* create mqtt client */ 76 | mqtt.createClient({ 77 | uri: 'mqtt://test.mosquitto.org:1883', 78 | clientId: 'your_client_id' 79 | }).then(function(client) { 80 | 81 | client.on('closed', function() { 82 | console.log('mqtt.event.closed'); 83 | 84 | }); 85 | 86 | client.on('error', function(msg) { 87 | console.log('mqtt.event.error', msg); 88 | 89 | }); 90 | 91 | client.on('message', function(msg) { 92 | console.log('mqtt.event.message', msg); 93 | }); 94 | 95 | client.on('connect', function() { 96 | console.log('connected'); 97 | client.subscribe('/data', 0); 98 | client.publish('/data', "test", 0, false); 99 | }); 100 | 101 | client.connect(); 102 | }).catch(function(err){ 103 | console.log(err); 104 | }); 105 | 106 | ``` 107 | 108 | ## API 109 | * `mqtt.createClient(options)` create new client instance with `options`, async operation 110 | - `uri`: `protocol://host:port`, protocol is [mqtt | mqtts] 111 | - `host`: ipaddress or host name (override by uri if set) 112 | - `port`: port number (override by uri if set) 113 | - `tls`: true/false (override by uri if set to mqtts or wss) 114 | - `user`: string username 115 | - `pass`: string password 116 | - `auth`: true/false - override = true if `user` or `pass` exist 117 | - `clientId`: string client id 118 | - `keepalive` 119 | 120 | * `client` 121 | - `on(event, callback)`: add event listener for 122 | + event: `connect` - client connected 123 | + event: `closed` - client disconnected 124 | + event: `error` - error 125 | + event: `message` - message object 126 | - `connect`: begin connection 127 | - `disconnect`: disconnect 128 | - `subscribe(topic, qos)` 129 | - `publish(topic, payload, qos, retain)` 130 | 131 | * `message` 132 | - `retain`: *boolean* `false` 133 | - `qos`: *number* `2` 134 | - `data`: *string* `"test message"` 135 | - `topic`: *string* `"/data"` 136 | 137 | ## Todo 138 | 139 | * [ ] todo 140 | 141 | 142 | ## LICENSE 143 | 144 | ``` 145 | INHERIT FROM MQTT LIBRARY (progress) 146 | ``` 147 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:1.2.3' 8 | } 9 | } 10 | 11 | apply plugin: 'com.android.library' 12 | 13 | android { 14 | compileSdkVersion 23 15 | buildToolsVersion "23.0.1" 16 | 17 | defaultConfig { 18 | minSdkVersion 16 19 | targetSdkVersion 21 20 | versionCode 1 21 | versionName "1.0" 22 | } 23 | lintOptions { 24 | abortOnError false 25 | } 26 | } 27 | 28 | repositories { 29 | mavenCentral() 30 | maven { 31 | url "https://repo.eclipse.org/content/repositories/paho-releases/" 32 | } 33 | } 34 | 35 | dependencies { 36 | compile 'com.facebook.react:react-native:0.19.+' 37 | compile('org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2') { 38 | exclude module: 'support-v4' 39 | } 40 | compile 'org.bouncycastle:bcprov-jdk15on:1.54' 41 | 42 | } 43 | 44 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /android/src/main/java/com/tuanpm/RCTMqtt/RCTMqttModule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by TuanPM (tuanpm@live.com) on 1/4/16. 3 | */ 4 | 5 | package com.tuanpm.RCTMqtt; 6 | 7 | import android.net.Uri; 8 | import android.os.Environment; 9 | import android.provider.MediaStore; 10 | import android.util.Base64; 11 | import android.util.Log; 12 | import android.widget.Toast; 13 | import android.os.AsyncTask; 14 | import android.os.Bundle; 15 | 16 | import com.facebook.react.bridge.*; 17 | 18 | import javax.annotation.Nullable; 19 | import java.io.*; 20 | import java.text.SimpleDateFormat; 21 | import java.util.Collections; 22 | import java.util.Date; 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | import java.util.List; 26 | 27 | import com.facebook.react.bridge.ReadableMap; 28 | import com.facebook.react.bridge.WritableMap; 29 | import com.facebook.react.LifecycleState; 30 | import com.facebook.react.ReactInstanceManager; 31 | import com.facebook.react.ReactRootView; 32 | import com.facebook.react.bridge.ReactContext; 33 | import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; 34 | import com.facebook.react.modules.core.DeviceEventManagerModule; 35 | import com.facebook.react.shell.MainReactPackage; 36 | 37 | import java.util.AbstractList; 38 | import java.util.Random; 39 | 40 | public class RCTMqttModule extends ReactContextBaseJavaModule { 41 | 42 | private static final String TAG = "RCTMqttModule"; 43 | private final ReactApplicationContext _reactContext; 44 | private HashMap clients; 45 | 46 | public RCTMqttModule(ReactApplicationContext reactContext) { 47 | super(reactContext); 48 | _reactContext = reactContext; 49 | clients = new HashMap(); 50 | } 51 | 52 | @Override 53 | public String getName() { 54 | return "Mqtt"; 55 | } 56 | 57 | @ReactMethod 58 | public void createClient(final ReadableMap _options, Promise promise) { 59 | int clientRef = randInt(1000, 9999); 60 | RCTMqtt client = new RCTMqtt(clientRef, _reactContext, _options); 61 | client.setCallback(); 62 | clients.put(clientRef, client); 63 | promise.resolve(clientRef); 64 | Log.d(TAG, "ClientRef:" + clientRef); 65 | } 66 | 67 | @ReactMethod 68 | public void connect(final int clientRef) { 69 | clients.get(clientRef).connect(); 70 | } 71 | 72 | @ReactMethod 73 | public void disconnect(final int clientRef) { 74 | clients.get(clientRef).disconnect(); 75 | } 76 | 77 | @ReactMethod 78 | public void removeClient(final int clientRef, Promise promise) { 79 | clients.remove(clientRef); 80 | promise.resolve(clientRef); 81 | } 82 | 83 | @ReactMethod 84 | public void subscribe(final int clientRef, final String topic, final int qos) { 85 | clients.get(clientRef).subscribe(topic, qos); 86 | } 87 | 88 | @ReactMethod 89 | public void publish(final int clientRef, final String topic, final String payload, final int qos, final boolean retain) { 90 | clients.get(clientRef).publish(topic, payload, qos, retain); 91 | } 92 | 93 | public static int randInt(int min, int max) { 94 | 95 | // NOTE: This will (intentionally) not run as written so that folks 96 | // copy-pasting have to think about how to initialize their 97 | // Random instance. Initialization of the Random instance is outside 98 | // the main scope of the question, but some decent options are to have 99 | // a field that is initialized once and then re-used as needed or to 100 | // use ThreadLocalRandom (if using at least Java 1.7). 101 | Random rand = new Random(); 102 | 103 | // nextInt is normally exclusive of the top value, 104 | // so add 1 to make it inclusive 105 | int randomNum = rand.nextInt((max - min) + 1) + min; 106 | 107 | return randomNum; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /android/src/main/java/com/tuanpm/RCTMqtt/RCTMqttPackage.java: -------------------------------------------------------------------------------- 1 | package com.tuanpm.RCTMqtt; 2 | 3 | import java.util.Arrays; 4 | import java.util.ArrayList; 5 | import java.util.Collections; 6 | import java.util.List; 7 | import android.util.Log; 8 | 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.bridge.NativeModule; 11 | import com.facebook.react.bridge.ReactApplicationContext; 12 | import com.facebook.react.uimanager.ViewManager; 13 | import com.facebook.react.bridge.JavaScriptModule; 14 | public class RCTMqttPackage implements ReactPackage { 15 | 16 | @Override 17 | public List createNativeModules( 18 | ReactApplicationContext reactContext) { 19 | 20 | List modules = new ArrayList<>(); 21 | 22 | modules.add(new RCTMqttModule(reactContext)); 23 | 24 | return modules; 25 | } 26 | @Override 27 | public List> createJSModules() { 28 | return Collections.emptyList(); 29 | } 30 | 31 | @Override 32 | public List createViewManagers( 33 | ReactApplicationContext reactContext) { 34 | return Collections.emptyList(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import { 2 | DeviceEventEmitter, 3 | NativeModules 4 | } from 'react-native'; 5 | 6 | var Mqtt = NativeModules.Mqtt; 7 | 8 | var MqttClient = function(options, clientRef){ 9 | this.options = options; 10 | this.clientRef = clientRef; 11 | this.eventHandler = {}; 12 | 13 | this.dispatchEvent = function(data) { 14 | 15 | if(data && data.clientRef == this.clientRef && data.event) { 16 | 17 | if(this.eventHandler[data.event]) { 18 | this.eventHandler[data.event](data.message); 19 | } 20 | } 21 | } 22 | } 23 | 24 | MqttClient.prototype.on = function (event, callback) { 25 | console.log('setup event', event); 26 | this.eventHandler[event] = callback; 27 | } 28 | 29 | MqttClient.prototype.connect = function () { 30 | Mqtt.connect(this.clientRef); 31 | } 32 | 33 | MqttClient.prototype.disconnect = function () { 34 | Mqtt.disconnect(this.clientRef); 35 | } 36 | 37 | MqttClient.prototype.subscribe = function (topic, qos) { 38 | Mqtt.subscribe(this.clientRef, topic, qos); 39 | } 40 | 41 | MqttClient.prototype.publish = function(topic, payload, qos, retain) { 42 | Mqtt.publish(this.clientRef, topic, payload, qos, retain); 43 | } 44 | 45 | module.exports = { 46 | clients: [], 47 | eventHandler: null, 48 | dispatchEvents: function(data) { 49 | this.clients.forEach(function(client) { 50 | client.dispatchEvent(data); 51 | }); 52 | }, 53 | setEventHandler: function() { 54 | this.eventHandler = DeviceEventEmitter.addListener("mqtt_events", (data) => this.dispatchEvents(data)); 55 | }, 56 | createClient: async function(options) { 57 | if(options.uri) { 58 | var pattern = /^((mqtt[s]?|ws[s]?)?:(\/\/)([0-9a-zA-Z_\.]*):?(\d+))$/; 59 | var matches = options.uri.match(pattern); 60 | var protocol = matches[2]; 61 | var host = matches[4]; 62 | var port = matches[5]; 63 | 64 | options.port = parseInt(port); 65 | options.host = host; 66 | options.protocol = 'tcp'; 67 | 68 | 69 | if(protocol == 'wss' || protocol == 'mqtts') { 70 | options.tls = true; 71 | } 72 | if(protocol == 'ws' || protocol == 'wss') { 73 | options.protocol = 'ws'; 74 | } 75 | 76 | } 77 | 78 | let clientRef = await Mqtt.createClient(options); 79 | 80 | var client = new MqttClient(options, clientRef); 81 | 82 | /* Listen mqtt event */ 83 | if(this.eventHandler === null) { 84 | this.setEventHandler(); 85 | } 86 | this.clients.push(client); 87 | 88 | return client; 89 | }, 90 | removeClient: function(client) { 91 | Mqtt.removeClient(client.clientRef) 92 | .then(() => { 93 | var clientIdx = this.clients.indexOf(client); 94 | 95 | if (clientIdx > -1) { 96 | this.clients.splice(clientIdx, 1); 97 | } 98 | 99 | if (this.clients.length > 0) { 100 | if (this.eventHandler !== null) { 101 | this.eventHandler.remove(); 102 | this.setEventHandler(); 103 | } 104 | } 105 | }); 106 | } 107 | }; 108 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Mqtt.h: -------------------------------------------------------------------------------- 1 | // 2 | // Mqtt.h 3 | // RCTMqtt 4 | // 5 | // Created by Tuan PM on 2/14/16. 6 | // Copyright © 2016 Tuan PM. All rights reserved. 7 | // 8 | #import 9 | #import "RCTBridgeModule.h" 10 | #import "RCTLog.h" 11 | #import "RCTUtils.h" 12 | #import "RCTEventDispatcher.h" 13 | 14 | #import 15 | #import 16 | #import 17 | 18 | 19 | 20 | @interface Mqtt : NSObject 21 | 22 | - (Mqtt*) initWithBrigde:(RCTBridge *) bridge 23 | options:(NSDictionary *) options 24 | clientRef:(int) clientRef; 25 | - (void) connect; 26 | - (void) disconnect; 27 | - (void) subscribe:(NSString *)topic qos:(NSNumber *)qos; 28 | - (void) publish:(NSString *) topic data:(NSData *)data qos:(NSNumber *)qos retain:(BOOL) retain; 29 | @end -------------------------------------------------------------------------------- /ios/RCTMqtt/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '9.0' 2 | 3 | inhibit_all_warnings! 4 | 5 | pod 'MQTTClient' 6 | pod 'MQTTClient/Websocket' 7 | 8 | target "RCTMqtt" do 9 | end 10 | 11 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaLumberjack (2.2.0): 3 | - CocoaLumberjack/Default (= 2.2.0) 4 | - CocoaLumberjack/Extensions (= 2.2.0) 5 | - CocoaLumberjack/Core (2.2.0) 6 | - CocoaLumberjack/Default (2.2.0): 7 | - CocoaLumberjack/Core 8 | - CocoaLumberjack/Extensions (2.2.0): 9 | - CocoaLumberjack/Default 10 | - MQTTClient (0.6.9): 11 | - MQTTClient/Core (= 0.6.9) 12 | - MQTTClient/Core (0.6.9): 13 | - CocoaLumberjack 14 | - MQTTClient/Websocket (0.6.9): 15 | - MQTTClient/Core 16 | - SocketRocket 17 | - SocketRocket (0.4.2) 18 | 19 | DEPENDENCIES: 20 | - MQTTClient 21 | - MQTTClient/Websocket 22 | 23 | SPEC CHECKSUMS: 24 | CocoaLumberjack: 17fe8581f84914d5d7e6360f7c70022b173c3ae0 25 | MQTTClient: db15b4359780774a3ad876672624d7bd6f8a04d0 26 | SocketRocket: ffe08119b00ef982f6c37052a4705a057c8494ad 27 | 28 | COCOAPODS: 0.39.0 29 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/CocoaLumberjack.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | /** 17 | * Welcome to CocoaLumberjack! 18 | * 19 | * The project page has a wealth of documentation if you have any questions. 20 | * https://github.com/CocoaLumberjack/CocoaLumberjack 21 | * 22 | * If you're new to the project you may wish to read "Getting Started" at: 23 | * Documentation/GettingStarted.md 24 | * 25 | * Otherwise, here is a quick refresher. 26 | * There are three steps to using the macros: 27 | * 28 | * Step 1: 29 | * Import the header in your implementation or prefix file: 30 | * 31 | * #import 32 | * 33 | * Step 2: 34 | * Define your logging level in your implementation file: 35 | * 36 | * // Log levels: off, error, warn, info, verbose 37 | * static const DDLogLevel ddLogLevel = DDLogLevelVerbose; 38 | * 39 | * Step 2 [3rd party frameworks]: 40 | * 41 | * Define your LOG_LEVEL_DEF to a different variable/function than ddLogLevel: 42 | * 43 | * // #undef LOG_LEVEL_DEF // Undefine first only if needed 44 | * #define LOG_LEVEL_DEF myLibLogLevel 45 | * 46 | * Define your logging level in your implementation file: 47 | * 48 | * // Log levels: off, error, warn, info, verbose 49 | * static const DDLogLevel myLibLogLevel = DDLogLevelVerbose; 50 | * 51 | * Step 3: 52 | * Replace your NSLog statements with DDLog statements according to the severity of the message. 53 | * 54 | * NSLog(@"Fatal error, no dohickey found!"); -> DDLogError(@"Fatal error, no dohickey found!"); 55 | * 56 | * DDLog works exactly the same as NSLog. 57 | * This means you can pass it multiple variables just like NSLog. 58 | **/ 59 | 60 | #import 61 | 62 | // Disable legacy macros 63 | #ifndef DD_LEGACY_MACROS 64 | #define DD_LEGACY_MACROS 0 65 | #endif 66 | 67 | // Core 68 | #import "DDLog.h" 69 | 70 | // Main macros 71 | #import "DDLogMacros.h" 72 | #import "DDAssertMacros.h" 73 | 74 | // Capture ASL 75 | #import "DDASLLogCapture.h" 76 | 77 | // Loggers 78 | #import "DDTTYLogger.h" 79 | #import "DDASLLogger.h" 80 | #import "DDFileLogger.h" 81 | 82 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/CocoaLumberjack.swift: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2014-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | import Foundation 17 | 18 | extension DDLogFlag { 19 | public static func fromLogLevel(logLevel: DDLogLevel) -> DDLogFlag { 20 | return DDLogFlag(rawValue: logLevel.rawValue) 21 | } 22 | 23 | public init(_ logLevel: DDLogLevel) { 24 | self = DDLogFlag(rawValue: logLevel.rawValue) 25 | } 26 | 27 | ///returns the log level, or the lowest equivalant. 28 | public func toLogLevel() -> DDLogLevel { 29 | if let ourValid = DDLogLevel(rawValue: self.rawValue) { 30 | return ourValid 31 | } else { 32 | let logFlag:DDLogFlag = self 33 | 34 | if logFlag.contains(.Verbose) { 35 | return .Verbose 36 | } else if logFlag.contains(.Debug) { 37 | return .Debug 38 | } else if logFlag.contains(.Info) { 39 | return .Info 40 | } else if logFlag.contains(.Warning) { 41 | return .Warning 42 | } else if logFlag.contains(.Error) { 43 | return .Error 44 | } else { 45 | return .Off 46 | } 47 | } 48 | } 49 | } 50 | 51 | public var defaultDebugLevel = DDLogLevel.Verbose 52 | 53 | public func resetDefaultDebugLevel() { 54 | defaultDebugLevel = DDLogLevel.Verbose 55 | } 56 | 57 | public func SwiftLogMacro(isAsynchronous: Bool, level: DDLogLevel, flag flg: DDLogFlag, context: Int = 0, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UInt = __LINE__, tag: AnyObject? = nil, @autoclosure string: () -> String) { 58 | if level.rawValue & flg.rawValue != 0 { 59 | // Tell the DDLogMessage constructor to copy the C strings that get passed to it. 60 | // Using string interpolation to prevent integer overflow warning when using StaticString.stringValue 61 | let logMessage = DDLogMessage(message: string(), level: level, flag: flg, context: context, file: "\(file)", function: "\(function)", line: line, tag: tag, options: [.CopyFile, .CopyFunction], timestamp: nil) 62 | DDLog.log(isAsynchronous, message: logMessage) 63 | } 64 | } 65 | 66 | public func DDLogDebug(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UInt = __LINE__, tag: AnyObject? = nil, asynchronous async: Bool = true) { 67 | SwiftLogMacro(async, level: level, flag: .Debug, context: context, file: file, function: function, line: line, tag: tag, string: logText) 68 | } 69 | 70 | public func DDLogInfo(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UInt = __LINE__, tag: AnyObject? = nil, asynchronous async: Bool = true) { 71 | SwiftLogMacro(async, level: level, flag: .Info, context: context, file: file, function: function, line: line, tag: tag, string: logText) 72 | } 73 | 74 | public func DDLogWarn(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UInt = __LINE__, tag: AnyObject? = nil, asynchronous async: Bool = true) { 75 | SwiftLogMacro(async, level: level, flag: .Warning, context: context, file: file, function: function, line: line, tag: tag, string: logText) 76 | } 77 | 78 | public func DDLogVerbose(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UInt = __LINE__, tag: AnyObject? = nil, asynchronous async: Bool = true) { 79 | SwiftLogMacro(async, level: level, flag: .Verbose, context: context, file: file, function: function, line: line, tag: tag, string: logText) 80 | } 81 | 82 | public func DDLogError(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UInt = __LINE__, tag: AnyObject? = nil, asynchronous async: Bool = false) { 83 | SwiftLogMacro(async, level: level, flag: .Error, context: context, file: file, function: function, line: line, tag: tag, string: logText) 84 | } 85 | 86 | /// Analogous to the C preprocessor macro `THIS_FILE`. 87 | public func CurrentFileName(fileName: StaticString = __FILE__) -> String { 88 | // Using string interpolation to prevent integer overflow warning when using StaticString.stringValue 89 | // This double-casting to NSString is necessary as changes to how Swift handles NSPathUtilities requres the string to be an NSString 90 | return (("\(fileName)" as NSString).lastPathComponent as NSString).stringByDeletingPathExtension 91 | } 92 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDASLLogCapture.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | #import "DDASLLogger.h" 17 | 18 | @protocol DDLogger; 19 | 20 | /** 21 | * This class provides the ability to capture the ASL (Apple System Logs) 22 | */ 23 | @interface DDASLLogCapture : NSObject 24 | 25 | /** 26 | * Start capturing logs 27 | */ 28 | + (void)start; 29 | 30 | /** 31 | * Stop capturing logs 32 | */ 33 | + (void)stop; 34 | 35 | /** 36 | * Returns the current capture level. 37 | * @note Default log level: DDLogLevelVerbose (i.e. capture all ASL messages). 38 | */ 39 | + (DDLogLevel)captureLevel; 40 | 41 | /** 42 | * Set the capture level 43 | * 44 | * @param level new level 45 | */ 46 | + (void)setCaptureLevel:(DDLogLevel)level; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDASLLogger.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | #import 17 | 18 | // Disable legacy macros 19 | #ifndef DD_LEGACY_MACROS 20 | #define DD_LEGACY_MACROS 0 21 | #endif 22 | 23 | #import "DDLog.h" 24 | 25 | // Custom key set on messages sent to ASL 26 | extern const char* const kDDASLKeyDDLog; 27 | 28 | // Value set for kDDASLKeyDDLog 29 | extern const char* const kDDASLDDLogValue; 30 | 31 | /** 32 | * This class provides a logger for the Apple System Log facility. 33 | * 34 | * As described in the "Getting Started" page, 35 | * the traditional NSLog() function directs its output to two places: 36 | * 37 | * - Apple System Log 38 | * - StdErr (if stderr is a TTY) so log statements show up in Xcode console 39 | * 40 | * To duplicate NSLog() functionality you can simply add this logger and a tty logger. 41 | * However, if you instead choose to use file logging (for faster performance), 42 | * you may choose to use a file logger and a tty logger. 43 | **/ 44 | @interface DDASLLogger : DDAbstractLogger 45 | 46 | /** 47 | * Singleton method 48 | * 49 | * @return the shared instance 50 | */ 51 | + (instancetype)sharedInstance; 52 | 53 | // Inherited from DDAbstractLogger 54 | 55 | // - (id )logFormatter; 56 | // - (void)setLogFormatter:(id )formatter; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDASLLogger.m: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | #import "DDASLLogger.h" 17 | #import 18 | 19 | #if !__has_feature(objc_arc) 20 | #error This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 21 | #endif 22 | 23 | const char* const kDDASLKeyDDLog = "DDLog"; 24 | 25 | const char* const kDDASLDDLogValue = "1"; 26 | 27 | static DDASLLogger *sharedInstance; 28 | 29 | @interface DDASLLogger () { 30 | aslclient _client; 31 | } 32 | 33 | @end 34 | 35 | 36 | @implementation DDASLLogger 37 | 38 | + (instancetype)sharedInstance { 39 | static dispatch_once_t DDASLLoggerOnceToken; 40 | 41 | dispatch_once(&DDASLLoggerOnceToken, ^{ 42 | sharedInstance = [[[self class] alloc] init]; 43 | }); 44 | 45 | return sharedInstance; 46 | } 47 | 48 | - (instancetype)init { 49 | if (sharedInstance != nil) { 50 | return nil; 51 | } 52 | 53 | if ((self = [super init])) { 54 | // A default asl client is provided for the main thread, 55 | // but background threads need to create their own client. 56 | 57 | _client = asl_open(NULL, "com.apple.console", 0); 58 | } 59 | 60 | return self; 61 | } 62 | 63 | - (void)logMessage:(DDLogMessage *)logMessage { 64 | // Skip captured log messages 65 | if ([logMessage->_fileName isEqualToString:@"DDASLLogCapture"]) { 66 | return; 67 | } 68 | 69 | NSString * message = _logFormatter ? [_logFormatter formatLogMessage:logMessage] : logMessage->_message; 70 | 71 | if (logMessage) { 72 | const char *msg = [message UTF8String]; 73 | 74 | size_t aslLogLevel; 75 | switch (logMessage->_flag) { 76 | // Note: By default ASL will filter anything above level 5 (Notice). 77 | // So our mappings shouldn't go above that level. 78 | case DDLogFlagError : aslLogLevel = ASL_LEVEL_CRIT; break; 79 | case DDLogFlagWarning : aslLogLevel = ASL_LEVEL_ERR; break; 80 | case DDLogFlagInfo : aslLogLevel = ASL_LEVEL_WARNING; break; // Regular NSLog's level 81 | case DDLogFlagDebug : 82 | case DDLogFlagVerbose : 83 | default : aslLogLevel = ASL_LEVEL_NOTICE; break; 84 | } 85 | 86 | static char const *const level_strings[] = { "0", "1", "2", "3", "4", "5", "6", "7" }; 87 | 88 | // NSLog uses the current euid to set the ASL_KEY_READ_UID. 89 | uid_t const readUID = geteuid(); 90 | 91 | char readUIDString[16]; 92 | #ifndef NS_BLOCK_ASSERTIONS 93 | int l = snprintf(readUIDString, sizeof(readUIDString), "%d", readUID); 94 | #else 95 | snprintf(readUIDString, sizeof(readUIDString), "%d", readUID); 96 | #endif 97 | 98 | NSAssert(l < sizeof(readUIDString), 99 | @"Formatted euid is too long."); 100 | NSAssert(aslLogLevel < (sizeof(level_strings) / sizeof(level_strings[0])), 101 | @"Unhandled ASL log level."); 102 | 103 | aslmsg m = asl_new(ASL_TYPE_MSG); 104 | if (m != NULL) { 105 | if (asl_set(m, ASL_KEY_LEVEL, level_strings[aslLogLevel]) == 0 && 106 | asl_set(m, ASL_KEY_MSG, msg) == 0 && 107 | asl_set(m, ASL_KEY_READ_UID, readUIDString) == 0 && 108 | asl_set(m, kDDASLKeyDDLog, kDDASLDDLogValue) == 0) { 109 | asl_send(_client, m); 110 | } 111 | asl_free(m); 112 | } 113 | //TODO handle asl_* failures non-silently? 114 | } 115 | } 116 | 117 | - (NSString *)loggerName { 118 | return @"cocoa.lumberjack.aslLogger"; 119 | } 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDAbstractDatabaseLogger.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | // Disable legacy macros 17 | #ifndef DD_LEGACY_MACROS 18 | #define DD_LEGACY_MACROS 0 19 | #endif 20 | 21 | #import "DDLog.h" 22 | 23 | /** 24 | * This class provides an abstract implementation of a database logger. 25 | * 26 | * That is, it provides the base implementation for a database logger to build atop of. 27 | * All that is needed for a concrete database logger is to extend this class 28 | * and override the methods in the implementation file that are prefixed with "db_". 29 | **/ 30 | @interface DDAbstractDatabaseLogger : DDAbstractLogger { 31 | 32 | @protected 33 | NSUInteger _saveThreshold; 34 | NSTimeInterval _saveInterval; 35 | NSTimeInterval _maxAge; 36 | NSTimeInterval _deleteInterval; 37 | BOOL _deleteOnEverySave; 38 | 39 | BOOL _saveTimerSuspended; 40 | NSUInteger _unsavedCount; 41 | dispatch_time_t _unsavedTime; 42 | dispatch_source_t _saveTimer; 43 | dispatch_time_t _lastDeleteTime; 44 | dispatch_source_t _deleteTimer; 45 | } 46 | 47 | /** 48 | * Specifies how often to save the data to disk. 49 | * Since saving is an expensive operation (disk io) it is not done after every log statement. 50 | * These properties allow you to configure how/when the logger saves to disk. 51 | * 52 | * A save is done when either (whichever happens first): 53 | * 54 | * - The number of unsaved log entries reaches saveThreshold 55 | * - The amount of time since the oldest unsaved log entry was created reaches saveInterval 56 | * 57 | * You can optionally disable the saveThreshold by setting it to zero. 58 | * If you disable the saveThreshold you are entirely dependent on the saveInterval. 59 | * 60 | * You can optionally disable the saveInterval by setting it to zero (or a negative value). 61 | * If you disable the saveInterval you are entirely dependent on the saveThreshold. 62 | * 63 | * It's not wise to disable both saveThreshold and saveInterval. 64 | * 65 | * The default saveThreshold is 500. 66 | * The default saveInterval is 60 seconds. 67 | **/ 68 | @property (assign, readwrite) NSUInteger saveThreshold; 69 | 70 | /** 71 | * See the description for the `saveThreshold` property 72 | */ 73 | @property (assign, readwrite) NSTimeInterval saveInterval; 74 | 75 | /** 76 | * It is likely you don't want the log entries to persist forever. 77 | * Doing so would allow the database to grow infinitely large over time. 78 | * 79 | * The maxAge property provides a way to specify how old a log statement can get 80 | * before it should get deleted from the database. 81 | * 82 | * The deleteInterval specifies how often to sweep for old log entries. 83 | * Since deleting is an expensive operation (disk io) is is done on a fixed interval. 84 | * 85 | * An alternative to the deleteInterval is the deleteOnEverySave option. 86 | * This specifies that old log entries should be deleted during every save operation. 87 | * 88 | * You can optionally disable the maxAge by setting it to zero (or a negative value). 89 | * If you disable the maxAge then old log statements are not deleted. 90 | * 91 | * You can optionally disable the deleteInterval by setting it to zero (or a negative value). 92 | * 93 | * If you disable both deleteInterval and deleteOnEverySave then old log statements are not deleted. 94 | * 95 | * It's not wise to enable both deleteInterval and deleteOnEverySave. 96 | * 97 | * The default maxAge is 7 days. 98 | * The default deleteInterval is 5 minutes. 99 | * The default deleteOnEverySave is NO. 100 | **/ 101 | @property (assign, readwrite) NSTimeInterval maxAge; 102 | 103 | /** 104 | * See the description for the `maxAge` property 105 | */ 106 | @property (assign, readwrite) NSTimeInterval deleteInterval; 107 | 108 | /** 109 | * See the description for the `maxAge` property 110 | */ 111 | @property (assign, readwrite) BOOL deleteOnEverySave; 112 | 113 | /** 114 | * Forces a save of any pending log entries (flushes log entries to disk). 115 | **/ 116 | - (void)savePendingLogEntries; 117 | 118 | /** 119 | * Removes any log entries that are older than maxAge. 120 | **/ 121 | - (void)deleteOldLogEntries; 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDAssertMacros.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | /** 17 | * NSAsset replacement that will output a log message even when assertions are disabled. 18 | **/ 19 | #define DDAssert(condition, frmt, ...) \ 20 | if (!(condition)) { \ 21 | NSString *description = [NSString stringWithFormat:frmt, ## __VA_ARGS__]; \ 22 | DDLogError(@"%@", description); \ 23 | NSAssert(NO, description); \ 24 | } 25 | #define DDAssertCondition(condition) DDAssert(condition, @"Condition not satisfied: %s", #condition) 26 | 27 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDLegacyMacros.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | /** 17 | * Legacy macros used for 1.9.x backwards compatibility. 18 | * 19 | * Imported by default when importing a DDLog.h directly and DD_LEGACY_MACROS is not defined and set to 0. 20 | **/ 21 | #if DD_LEGACY_MACROS 22 | 23 | #warning CocoaLumberjack 1.9.x legacy macros enabled. \ 24 | Disable legacy macros by importing CocoaLumberjack.h or DDLogMacros.h instead of DDLog.h or add `#define DD_LEGACY_MACROS 0` before importing DDLog.h. 25 | 26 | #ifndef LOG_LEVEL_DEF 27 | #define LOG_LEVEL_DEF ddLogLevel 28 | #endif 29 | 30 | #define LOG_FLAG_ERROR DDLogFlagError 31 | #define LOG_FLAG_WARN DDLogFlagWarning 32 | #define LOG_FLAG_INFO DDLogFlagInfo 33 | #define LOG_FLAG_DEBUG DDLogFlagDebug 34 | #define LOG_FLAG_VERBOSE DDLogFlagVerbose 35 | 36 | #define LOG_LEVEL_OFF DDLogLevelOff 37 | #define LOG_LEVEL_ERROR DDLogLevelError 38 | #define LOG_LEVEL_WARN DDLogLevelWarning 39 | #define LOG_LEVEL_INFO DDLogLevelInfo 40 | #define LOG_LEVEL_DEBUG DDLogLevelDebug 41 | #define LOG_LEVEL_VERBOSE DDLogLevelVerbose 42 | #define LOG_LEVEL_ALL DDLogLevelAll 43 | 44 | #define LOG_ASYNC_ENABLED YES 45 | 46 | #define LOG_ASYNC_ERROR ( NO && LOG_ASYNC_ENABLED) 47 | #define LOG_ASYNC_WARN (YES && LOG_ASYNC_ENABLED) 48 | #define LOG_ASYNC_INFO (YES && LOG_ASYNC_ENABLED) 49 | #define LOG_ASYNC_DEBUG (YES && LOG_ASYNC_ENABLED) 50 | #define LOG_ASYNC_VERBOSE (YES && LOG_ASYNC_ENABLED) 51 | 52 | #define LOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \ 53 | [DDLog log : isAsynchronous \ 54 | level : lvl \ 55 | flag : flg \ 56 | context : ctx \ 57 | file : __FILE__ \ 58 | function : fnct \ 59 | line : __LINE__ \ 60 | tag : atag \ 61 | format : (frmt), ## __VA_ARGS__] 62 | 63 | #define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \ 64 | do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, ##__VA_ARGS__); } while(0) 65 | 66 | #define LOG_OBJC_MAYBE(async, lvl, flg, ctx, frmt, ...) \ 67 | LOG_MAYBE(async, lvl, flg, ctx, __PRETTY_FUNCTION__, frmt, ## __VA_ARGS__) 68 | 69 | #define DDLogError(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_ERROR, LOG_LEVEL_DEF, LOG_FLAG_ERROR, 0, frmt, ##__VA_ARGS__) 70 | #define DDLogWarn(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_WARN, LOG_LEVEL_DEF, LOG_FLAG_WARN, 0, frmt, ##__VA_ARGS__) 71 | #define DDLogInfo(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_INFO, LOG_LEVEL_DEF, LOG_FLAG_INFO, 0, frmt, ##__VA_ARGS__) 72 | #define DDLogDebug(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_DEBUG, LOG_LEVEL_DEF, LOG_FLAG_DEBUG, 0, frmt, ##__VA_ARGS__) 73 | #define DDLogVerbose(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_VERBOSE, LOG_LEVEL_DEF, LOG_FLAG_VERBOSE, 0, frmt, ##__VA_ARGS__) 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDLog+LOGV.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | // Disable legacy macros 17 | #ifndef DD_LEGACY_MACROS 18 | #define DD_LEGACY_MACROS 0 19 | #endif 20 | 21 | #import "DDLog.h" 22 | 23 | /** 24 | * The constant/variable/method responsible for controlling the current log level. 25 | **/ 26 | #ifndef LOG_LEVEL_DEF 27 | #define LOG_LEVEL_DEF ddLogLevel 28 | #endif 29 | 30 | /** 31 | * Whether async should be used by log messages, excluding error messages that are always sent sync. 32 | **/ 33 | #ifndef LOG_ASYNC_ENABLED 34 | #define LOG_ASYNC_ENABLED YES 35 | #endif 36 | 37 | /** 38 | * This is the single macro that all other macros below compile into. 39 | * This big multiline macro makes all the other macros easier to read. 40 | **/ 41 | #define LOGV_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, avalist) \ 42 | [DDLog log : isAsynchronous \ 43 | level : lvl \ 44 | flag : flg \ 45 | context : ctx \ 46 | file : __FILE__ \ 47 | function : fnct \ 48 | line : __LINE__ \ 49 | tag : atag \ 50 | format : frmt \ 51 | args : avalist] 52 | 53 | /** 54 | * Define version of the macro that only execute if the log level is above the threshold. 55 | * The compiled versions essentially look like this: 56 | * 57 | * if (logFlagForThisLogMsg & ddLogLevel) { execute log message } 58 | * 59 | * When LOG_LEVEL_DEF is defined as ddLogLevel. 60 | * 61 | * As shown further below, Lumberjack actually uses a bitmask as opposed to primitive log levels. 62 | * This allows for a great amount of flexibility and some pretty advanced fine grained logging techniques. 63 | * 64 | * Note that when compiler optimizations are enabled (as they are for your release builds), 65 | * the log messages above your logging threshold will automatically be compiled out. 66 | * 67 | * (If the compiler sees LOG_LEVEL_DEF/ddLogLevel declared as a constant, the compiler simply checks to see 68 | * if the 'if' statement would execute, and if not it strips it from the binary.) 69 | * 70 | * We also define shorthand versions for asynchronous and synchronous logging. 71 | **/ 72 | #define LOGV_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, avalist) \ 73 | do { if(lvl & flg) LOGV_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, avalist); } while(0) 74 | 75 | /** 76 | * Ready to use log macros with no context or tag. 77 | **/ 78 | #define DDLogVError(frmt, avalist) LOGV_MAYBE(NO, LOG_LEVEL_DEF, DDLogFlagError, 0, nil, __PRETTY_FUNCTION__, frmt, avalist) 79 | #define DDLogVWarn(frmt, avalist) LOGV_MAYBE(LOG_ASYNC_ENABLED, LOG_LEVEL_DEF, DDLogFlagWarning, 0, nil, __PRETTY_FUNCTION__, frmt, avalist) 80 | #define DDLogVInfo(frmt, avalist) LOGV_MAYBE(LOG_ASYNC_ENABLED, LOG_LEVEL_DEF, DDLogFlagInfo, 0, nil, __PRETTY_FUNCTION__, frmt, avalist) 81 | #define DDLogVDebug(frmt, avalist) LOGV_MAYBE(LOG_ASYNC_ENABLED, LOG_LEVEL_DEF, DDLogFlagDebug, 0, nil, __PRETTY_FUNCTION__, frmt, avalist) 82 | #define DDLogVVerbose(frmt, avalist) LOGV_MAYBE(LOG_ASYNC_ENABLED, LOG_LEVEL_DEF, DDLogFlagVerbose, 0, nil, __PRETTY_FUNCTION__, frmt, avalist) 83 | 84 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDLogMacros.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | // Disable legacy macros 17 | #ifndef DD_LEGACY_MACROS 18 | #define DD_LEGACY_MACROS 0 19 | #endif 20 | 21 | #import "DDLog.h" 22 | 23 | /** 24 | * The constant/variable/method responsible for controlling the current log level. 25 | **/ 26 | #ifndef LOG_LEVEL_DEF 27 | #define LOG_LEVEL_DEF ddLogLevel 28 | #endif 29 | 30 | /** 31 | * Whether async should be used by log messages, excluding error messages that are always sent sync. 32 | **/ 33 | #ifndef LOG_ASYNC_ENABLED 34 | #define LOG_ASYNC_ENABLED YES 35 | #endif 36 | 37 | /** 38 | * This is the single macro that all other macros below compile into. 39 | * This big multiline macro makes all the other macros easier to read. 40 | **/ 41 | #define LOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \ 42 | [DDLog log : isAsynchronous \ 43 | level : lvl \ 44 | flag : flg \ 45 | context : ctx \ 46 | file : __FILE__ \ 47 | function : fnct \ 48 | line : __LINE__ \ 49 | tag : atag \ 50 | format : (frmt), ## __VA_ARGS__] 51 | 52 | /** 53 | * Define version of the macro that only execute if the log level is above the threshold. 54 | * The compiled versions essentially look like this: 55 | * 56 | * if (logFlagForThisLogMsg & ddLogLevel) { execute log message } 57 | * 58 | * When LOG_LEVEL_DEF is defined as ddLogLevel. 59 | * 60 | * As shown further below, Lumberjack actually uses a bitmask as opposed to primitive log levels. 61 | * This allows for a great amount of flexibility and some pretty advanced fine grained logging techniques. 62 | * 63 | * Note that when compiler optimizations are enabled (as they are for your release builds), 64 | * the log messages above your logging threshold will automatically be compiled out. 65 | * 66 | * (If the compiler sees LOG_LEVEL_DEF/ddLogLevel declared as a constant, the compiler simply checks to see 67 | * if the 'if' statement would execute, and if not it strips it from the binary.) 68 | * 69 | * We also define shorthand versions for asynchronous and synchronous logging. 70 | **/ 71 | #define LOG_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, ...) \ 72 | do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, ##__VA_ARGS__); } while(0) 73 | 74 | /** 75 | * Ready to use log macros with no context or tag. 76 | **/ 77 | #define DDLogError(frmt, ...) LOG_MAYBE(NO, LOG_LEVEL_DEF, DDLogFlagError, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__) 78 | #define DDLogWarn(frmt, ...) LOG_MAYBE(LOG_ASYNC_ENABLED, LOG_LEVEL_DEF, DDLogFlagWarning, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__) 79 | #define DDLogInfo(frmt, ...) LOG_MAYBE(LOG_ASYNC_ENABLED, LOG_LEVEL_DEF, DDLogFlagInfo, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__) 80 | #define DDLogDebug(frmt, ...) LOG_MAYBE(LOG_ASYNC_ENABLED, LOG_LEVEL_DEF, DDLogFlagDebug, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__) 81 | #define DDLogVerbose(frmt, ...) LOG_MAYBE(LOG_ASYNC_ENABLED, LOG_LEVEL_DEF, DDLogFlagVerbose, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__) 82 | 83 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/DDTTYLogger.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | // Disable legacy macros 17 | #ifndef DD_LEGACY_MACROS 18 | #define DD_LEGACY_MACROS 0 19 | #endif 20 | 21 | #import "DDLog.h" 22 | 23 | #define LOG_CONTEXT_ALL INT_MAX 24 | 25 | #pragma clang diagnostic push 26 | #pragma clang diagnostic ignored "-Wunused-function" 27 | #if TARGET_OS_IPHONE 28 | // iOS 29 | #import 30 | typedef UIColor DDColor; 31 | static inline DDColor* DDMakeColor(CGFloat r, CGFloat g, CGFloat b) {return [DDColor colorWithRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f];} 32 | #elif defined(DD_CLI) || !__has_include() 33 | // OS X CLI 34 | #import "CLIColor.h" 35 | typedef CLIColor DDColor; 36 | static inline DDColor* DDMakeColor(CGFloat r, CGFloat g, CGFloat b) {return [DDColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f];} 37 | #else 38 | // OS X with AppKit 39 | #import 40 | typedef NSColor DDColor; 41 | static inline DDColor* DDMakeColor(CGFloat r, CGFloat g, CGFloat b) {return [DDColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f];} 42 | #endif 43 | #pragma clang diagnostic pop 44 | 45 | 46 | /** 47 | * This class provides a logger for Terminal output or Xcode console output, 48 | * depending on where you are running your code. 49 | * 50 | * As described in the "Getting Started" page, 51 | * the traditional NSLog() function directs it's output to two places: 52 | * 53 | * - Apple System Log (so it shows up in Console.app) 54 | * - StdErr (if stderr is a TTY, so log statements show up in Xcode console) 55 | * 56 | * To duplicate NSLog() functionality you can simply add this logger and an asl logger. 57 | * However, if you instead choose to use file logging (for faster performance), 58 | * you may choose to use only a file logger and a tty logger. 59 | **/ 60 | @interface DDTTYLogger : DDAbstractLogger 61 | 62 | /** 63 | * Singleton method 64 | */ 65 | + (instancetype)sharedInstance; 66 | 67 | /* Inherited from the DDLogger protocol: 68 | * 69 | * Formatters may optionally be added to any logger. 70 | * 71 | * If no formatter is set, the logger simply logs the message as it is given in logMessage, 72 | * or it may use its own built in formatting style. 73 | * 74 | * More information about formatters can be found here: 75 | * Documentation/CustomFormatters.md 76 | * 77 | * The actual implementation of these methods is inherited from DDAbstractLogger. 78 | 79 | - (id )logFormatter; 80 | - (void)setLogFormatter:(id )formatter; 81 | 82 | */ 83 | 84 | /** 85 | * Want to use different colors for different log levels? 86 | * Enable this property. 87 | * 88 | * If you run the application via the Terminal (not Xcode), 89 | * the logger will map colors to xterm-256color or xterm-color (if available). 90 | * 91 | * Xcode does NOT natively support colors in the Xcode debugging console. 92 | * You'll need to install the XcodeColors plugin to see colors in the Xcode console. 93 | * https://github.com/robbiehanson/XcodeColors 94 | * 95 | * The default value is NO. 96 | **/ 97 | @property (readwrite, assign) BOOL colorsEnabled; 98 | 99 | /** 100 | * When using a custom formatter you can set the `logMessage` method not to append 101 | * `\n` character after each output. This allows for some greater flexibility with 102 | * custom formatters. Default value is YES. 103 | **/ 104 | @property (nonatomic, readwrite, assign) BOOL automaticallyAppendNewlineForCustomFormatters; 105 | 106 | /** 107 | * The default color set (foregroundColor, backgroundColor) is: 108 | * 109 | * - DDLogFlagError = (red, nil) 110 | * - DDLogFlagWarning = (orange, nil) 111 | * 112 | * You can customize the colors however you see fit. 113 | * Please note that you are passing a flag, NOT a level. 114 | * 115 | * GOOD : [ttyLogger setForegroundColor:pink backgroundColor:nil forFlag:DDLogFlagInfo]; // <- Good :) 116 | * BAD : [ttyLogger setForegroundColor:pink backgroundColor:nil forFlag:DDLogLevelInfo]; // <- BAD! :( 117 | * 118 | * DDLogFlagInfo = 0...00100 119 | * DDLogLevelInfo = 0...00111 <- Would match DDLogFlagInfo and DDLogFlagWarning and DDLogFlagError 120 | * 121 | * If you run the application within Xcode, then the XcodeColors plugin is required. 122 | * 123 | * If you run the application from a shell, then DDTTYLogger will automatically map the given color to 124 | * the closest available color. (xterm-256color or xterm-color which have 256 and 16 supported colors respectively.) 125 | * 126 | * This method invokes setForegroundColor:backgroundColor:forFlag:context: and applies it to `LOG_CONTEXT_ALL`. 127 | **/ 128 | - (void)setForegroundColor:(DDColor *)txtColor backgroundColor:(DDColor *)bgColor forFlag:(DDLogFlag)mask; 129 | 130 | /** 131 | * Just like setForegroundColor:backgroundColor:flag, but allows you to specify a particular logging context. 132 | * 133 | * A logging context is often used to identify log messages coming from a 3rd party framework, 134 | * although logging context's can be used for many different functions. 135 | * 136 | * Use LOG_CONTEXT_ALL to set the deafult color for all contexts that have no specific color set defined. 137 | * 138 | * Logging context's are explained in further detail here: 139 | * Documentation/CustomContext.md 140 | **/ 141 | - (void)setForegroundColor:(DDColor *)txtColor backgroundColor:(DDColor *)bgColor forFlag:(DDLogFlag)mask context:(NSInteger)ctxt; 142 | 143 | /** 144 | * Similar to the methods above, but allows you to map DDLogMessage->tag to a particular color profile. 145 | * For example, you could do something like this: 146 | * 147 | * static NSString *const PurpleTag = @"PurpleTag"; 148 | * 149 | * #define DDLogPurple(frmt, ...) LOG_OBJC_TAG_MACRO(NO, 0, 0, 0, PurpleTag, frmt, ##__VA_ARGS__) 150 | * 151 | * And then where you configure CocoaLumberjack: 152 | * 153 | * purple = DDMakeColor((64/255.0), (0/255.0), (128/255.0)); 154 | * 155 | * or any UIColor/NSColor constructor. 156 | * 157 | * Note: For CLI OS X projects that don't link with AppKit use CLIColor objects instead 158 | * 159 | * [[DDTTYLogger sharedInstance] setForegroundColor:purple backgroundColor:nil forTag:PurpleTag]; 160 | * [DDLog addLogger:[DDTTYLogger sharedInstance]]; 161 | * 162 | * This would essentially give you a straight NSLog replacement that prints in purple: 163 | * 164 | * DDLogPurple(@"I'm a purple log message!"); 165 | **/ 166 | - (void)setForegroundColor:(DDColor *)txtColor backgroundColor:(DDColor *)bgColor forTag:(id )tag; 167 | 168 | /** 169 | * Clearing color profiles. 170 | **/ 171 | - (void)clearColorsForFlag:(DDLogFlag)mask; 172 | - (void)clearColorsForFlag:(DDLogFlag)mask context:(NSInteger)context; 173 | - (void)clearColorsForTag:(id )tag; 174 | - (void)clearColorsForAllFlags; 175 | - (void)clearColorsForAllTags; 176 | - (void)clearAllColors; 177 | 178 | @end 179 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/Extensions/DDContextFilterLogFormatter.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | #import 17 | 18 | // Disable legacy macros 19 | #ifndef DD_LEGACY_MACROS 20 | #define DD_LEGACY_MACROS 0 21 | #endif 22 | 23 | #import "DDLog.h" 24 | 25 | /** 26 | * This class provides a log formatter that filters log statements from a logging context not on the whitelist. 27 | * 28 | * A log formatter can be added to any logger to format and/or filter its output. 29 | * You can learn more about log formatters here: 30 | * Documentation/CustomFormatters.md 31 | * 32 | * You can learn more about logging context's here: 33 | * Documentation/CustomContext.md 34 | * 35 | * But here's a quick overview / refresher: 36 | * 37 | * Every log statement has a logging context. 38 | * These come from the underlying logging macros defined in DDLog.h. 39 | * The default logging context is zero. 40 | * You can define multiple logging context's for use in your application. 41 | * For example, logically separate parts of your app each have a different logging context. 42 | * Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context. 43 | **/ 44 | @interface DDContextWhitelistFilterLogFormatter : NSObject 45 | 46 | /** 47 | * Designated default initializer 48 | */ 49 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 50 | 51 | /** 52 | * Add a context to the whitelist 53 | * 54 | * @param loggingContext the context 55 | */ 56 | - (void)addToWhitelist:(NSUInteger)loggingContext; 57 | 58 | /** 59 | * Remove context from whitelist 60 | * 61 | * @param loggingContext the context 62 | */ 63 | - (void)removeFromWhitelist:(NSUInteger)loggingContext; 64 | 65 | /** 66 | * Return the whitelist 67 | */ 68 | @property (readonly, copy) NSArray *whitelist; 69 | 70 | /** 71 | * Check if a context is on the whitelist 72 | * 73 | * @param loggingContext the context 74 | */ 75 | - (BOOL)isOnWhitelist:(NSUInteger)loggingContext; 76 | 77 | @end 78 | 79 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 80 | #pragma mark - 81 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 82 | 83 | /** 84 | * This class provides a log formatter that filters log statements from a logging context on the blacklist. 85 | **/ 86 | @interface DDContextBlacklistFilterLogFormatter : NSObject 87 | 88 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 89 | 90 | /** 91 | * Add a context to the blacklist 92 | * 93 | * @param loggingContext the context 94 | */ 95 | - (void)addToBlacklist:(NSUInteger)loggingContext; 96 | 97 | /** 98 | * Remove context from blacklist 99 | * 100 | * @param loggingContext the context 101 | */ 102 | - (void)removeFromBlacklist:(NSUInteger)loggingContext; 103 | 104 | /** 105 | * Return the blacklist 106 | */ 107 | @property (readonly, copy) NSArray *blacklist; 108 | 109 | 110 | /** 111 | * Check if a context is on the blacklist 112 | * 113 | * @param loggingContext the context 114 | */ 115 | - (BOOL)isOnBlacklist:(NSUInteger)loggingContext; 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/Extensions/DDContextFilterLogFormatter.m: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | #import "DDContextFilterLogFormatter.h" 17 | #import 18 | 19 | #if !__has_feature(objc_arc) 20 | #error This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 21 | #endif 22 | 23 | @interface DDLoggingContextSet : NSObject 24 | 25 | - (void)addToSet:(NSUInteger)loggingContext; 26 | - (void)removeFromSet:(NSUInteger)loggingContext; 27 | 28 | @property (readonly, copy) NSArray *currentSet; 29 | 30 | - (BOOL)isInSet:(NSUInteger)loggingContext; 31 | 32 | @end 33 | 34 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 35 | #pragma mark - 36 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 37 | 38 | @interface DDContextWhitelistFilterLogFormatter () { 39 | DDLoggingContextSet *_contextSet; 40 | } 41 | 42 | @end 43 | 44 | 45 | @implementation DDContextWhitelistFilterLogFormatter 46 | 47 | - (instancetype)init { 48 | if ((self = [super init])) { 49 | _contextSet = [[DDLoggingContextSet alloc] init]; 50 | } 51 | 52 | return self; 53 | } 54 | 55 | - (void)addToWhitelist:(NSUInteger)loggingContext { 56 | [_contextSet addToSet:loggingContext]; 57 | } 58 | 59 | - (void)removeFromWhitelist:(NSUInteger)loggingContext { 60 | [_contextSet removeFromSet:loggingContext]; 61 | } 62 | 63 | - (NSArray *)whitelist { 64 | return [_contextSet currentSet]; 65 | } 66 | 67 | - (BOOL)isOnWhitelist:(NSUInteger)loggingContext { 68 | return [_contextSet isInSet:loggingContext]; 69 | } 70 | 71 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage { 72 | if ([self isOnWhitelist:logMessage->_context]) { 73 | return logMessage->_message; 74 | } else { 75 | return nil; 76 | } 77 | } 78 | 79 | @end 80 | 81 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 82 | #pragma mark - 83 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 84 | 85 | @interface DDContextBlacklistFilterLogFormatter () { 86 | DDLoggingContextSet *_contextSet; 87 | } 88 | 89 | @end 90 | 91 | 92 | @implementation DDContextBlacklistFilterLogFormatter 93 | 94 | - (instancetype)init { 95 | if ((self = [super init])) { 96 | _contextSet = [[DDLoggingContextSet alloc] init]; 97 | } 98 | 99 | return self; 100 | } 101 | 102 | - (void)addToBlacklist:(NSUInteger)loggingContext { 103 | [_contextSet addToSet:loggingContext]; 104 | } 105 | 106 | - (void)removeFromBlacklist:(NSUInteger)loggingContext { 107 | [_contextSet removeFromSet:loggingContext]; 108 | } 109 | 110 | - (NSArray *)blacklist { 111 | return [_contextSet currentSet]; 112 | } 113 | 114 | - (BOOL)isOnBlacklist:(NSUInteger)loggingContext { 115 | return [_contextSet isInSet:loggingContext]; 116 | } 117 | 118 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage { 119 | if ([self isOnBlacklist:logMessage->_context]) { 120 | return nil; 121 | } else { 122 | return logMessage->_message; 123 | } 124 | } 125 | 126 | @end 127 | 128 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 129 | #pragma mark - 130 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 131 | 132 | 133 | @interface DDLoggingContextSet () { 134 | OSSpinLock _lock; 135 | NSMutableSet *_set; 136 | } 137 | 138 | @end 139 | 140 | 141 | @implementation DDLoggingContextSet 142 | 143 | - (instancetype)init { 144 | if ((self = [super init])) { 145 | _set = [[NSMutableSet alloc] init]; 146 | } 147 | 148 | return self; 149 | } 150 | 151 | - (void)addToSet:(NSUInteger)loggingContext { 152 | OSSpinLockLock(&_lock); 153 | { 154 | [_set addObject:@(loggingContext)]; 155 | } 156 | OSSpinLockUnlock(&_lock); 157 | } 158 | 159 | - (void)removeFromSet:(NSUInteger)loggingContext { 160 | OSSpinLockLock(&_lock); 161 | { 162 | [_set removeObject:@(loggingContext)]; 163 | } 164 | OSSpinLockUnlock(&_lock); 165 | } 166 | 167 | - (NSArray *)currentSet { 168 | NSArray *result = nil; 169 | 170 | OSSpinLockLock(&_lock); 171 | { 172 | result = [_set allObjects]; 173 | } 174 | OSSpinLockUnlock(&_lock); 175 | 176 | return result; 177 | } 178 | 179 | - (BOOL)isInSet:(NSUInteger)loggingContext { 180 | BOOL result = NO; 181 | 182 | OSSpinLockLock(&_lock); 183 | { 184 | result = [_set containsObject:@(loggingContext)]; 185 | } 186 | OSSpinLockUnlock(&_lock); 187 | 188 | return result; 189 | } 190 | 191 | @end 192 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/Extensions/DDDispatchQueueLogFormatter.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | #import 17 | #import 18 | 19 | // Disable legacy macros 20 | #ifndef DD_LEGACY_MACROS 21 | #define DD_LEGACY_MACROS 0 22 | #endif 23 | 24 | #import "DDLog.h" 25 | 26 | /** 27 | * Log formatter mode 28 | */ 29 | typedef NS_ENUM(NSUInteger, DDDispatchQueueLogFormatterMode){ 30 | /** 31 | * This is the default option, means the formatter can be reused between multiple loggers and therefore is thread-safe. 32 | * There is, of course, a performance cost for the thread-safety 33 | */ 34 | DDDispatchQueueLogFormatterModeShareble = 0, 35 | /** 36 | * If the formatter will only be used by a single logger, then the thread-safety can be removed 37 | * @note: there is an assert checking if the formatter is added to multiple loggers and the mode is non-shareble 38 | */ 39 | DDDispatchQueueLogFormatterModeNonShareble, 40 | }; 41 | 42 | 43 | /** 44 | * This class provides a log formatter that prints the dispatch_queue label instead of the mach_thread_id. 45 | * 46 | * A log formatter can be added to any logger to format and/or filter its output. 47 | * You can learn more about log formatters here: 48 | * Documentation/CustomFormatters.md 49 | * 50 | * A typical `NSLog` (or `DDTTYLogger`) prints detailed info as `[:]`. 51 | * For example: 52 | * 53 | * `2011-10-17 20:21:45.435 AppName[19928:5207] Your log message here` 54 | * 55 | * Where: 56 | * `- 19928 = process id` 57 | * `- 5207 = thread id (mach_thread_id printed in hex)` 58 | * 59 | * When using grand central dispatch (GCD), this information is less useful. 60 | * This is because a single serial dispatch queue may be run on any thread from an internally managed thread pool. 61 | * For example: 62 | * 63 | * `2011-10-17 20:32:31.111 AppName[19954:4d07] Message from my_serial_dispatch_queue` 64 | * `2011-10-17 20:32:31.112 AppName[19954:5207] Message from my_serial_dispatch_queue` 65 | * `2011-10-17 20:32:31.113 AppName[19954:2c55] Message from my_serial_dispatch_queue` 66 | * 67 | * This formatter allows you to replace the standard `[box:info]` with the dispatch_queue name. 68 | * For example: 69 | * 70 | * `2011-10-17 20:32:31.111 AppName[img-scaling] Message from my_serial_dispatch_queue` 71 | * `2011-10-17 20:32:31.112 AppName[img-scaling] Message from my_serial_dispatch_queue` 72 | * `2011-10-17 20:32:31.113 AppName[img-scaling] Message from my_serial_dispatch_queue` 73 | * 74 | * If the dispatch_queue doesn't have a set name, then it falls back to the thread name. 75 | * If the current thread doesn't have a set name, then it falls back to the mach_thread_id in hex (like normal). 76 | * 77 | * Note: If manually creating your own background threads (via `NSThread/alloc/init` or `NSThread/detachNeThread`), 78 | * you can use `[[NSThread currentThread] setName:(NSString *)]`. 79 | **/ 80 | @interface DDDispatchQueueLogFormatter : NSObject 81 | 82 | /** 83 | * Standard init method. 84 | * Configure using properties as desired. 85 | **/ 86 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 87 | 88 | /** 89 | * Initializer with ability to set the queue mode 90 | * 91 | * @param mode choose between DDDispatchQueueLogFormatterModeShareble and DDDispatchQueueLogFormatterModeNonShareble, depending if the formatter is shared between several loggers or not 92 | */ 93 | - (instancetype)initWithMode:(DDDispatchQueueLogFormatterMode)mode; 94 | 95 | /** 96 | * The minQueueLength restricts the minimum size of the [detail box]. 97 | * If the minQueueLength is set to 0, there is no restriction. 98 | * 99 | * For example, say a dispatch_queue has a label of "diskIO": 100 | * 101 | * If the minQueueLength is 0: [diskIO] 102 | * If the minQueueLength is 4: [diskIO] 103 | * If the minQueueLength is 5: [diskIO] 104 | * If the minQueueLength is 6: [diskIO] 105 | * If the minQueueLength is 7: [diskIO ] 106 | * If the minQueueLength is 8: [diskIO ] 107 | * 108 | * The default minQueueLength is 0 (no minimum, so [detail box] won't be padded). 109 | * 110 | * If you want every [detail box] to have the exact same width, 111 | * set both minQueueLength and maxQueueLength to the same value. 112 | **/ 113 | @property (assign, atomic) NSUInteger minQueueLength; 114 | 115 | /** 116 | * The maxQueueLength restricts the number of characters that will be inside the [detail box]. 117 | * If the maxQueueLength is 0, there is no restriction. 118 | * 119 | * For example, say a dispatch_queue has a label of "diskIO": 120 | * 121 | * If the maxQueueLength is 0: [diskIO] 122 | * If the maxQueueLength is 4: [disk] 123 | * If the maxQueueLength is 5: [diskI] 124 | * If the maxQueueLength is 6: [diskIO] 125 | * If the maxQueueLength is 7: [diskIO] 126 | * If the maxQueueLength is 8: [diskIO] 127 | * 128 | * The default maxQueueLength is 0 (no maximum, so [detail box] won't be truncated). 129 | * 130 | * If you want every [detail box] to have the exact same width, 131 | * set both minQueueLength and maxQueueLength to the same value. 132 | **/ 133 | @property (assign, atomic) NSUInteger maxQueueLength; 134 | 135 | /** 136 | * Sometimes queue labels have long names like "com.apple.main-queue", 137 | * but you'd prefer something shorter like simply "main". 138 | * 139 | * This method allows you to set such preferred replacements. 140 | * The above example is set by default. 141 | * 142 | * To remove/undo a previous replacement, invoke this method with nil for the 'shortLabel' parameter. 143 | **/ 144 | - (NSString *)replacementStringForQueueLabel:(NSString *)longLabel; 145 | 146 | /** 147 | * See the `replacementStringForQueueLabel:` description 148 | */ 149 | - (void)setReplacementString:(NSString *)shortLabel forQueueLabel:(NSString *)longLabel; 150 | 151 | @end 152 | 153 | /** 154 | * Category on `DDDispatchQueueLogFormatter` to make method declarations easier to extend/modify 155 | **/ 156 | @interface DDDispatchQueueLogFormatter (OverridableMethods) 157 | 158 | /** 159 | * Date formatter default configuration 160 | */ 161 | - (void)configureDateFormatter:(NSDateFormatter *)dateFormatter; 162 | 163 | /** 164 | * Formatter method to transfrom from date to string 165 | */ 166 | - (NSString *)stringFromDate:(NSDate *)date; 167 | 168 | /** 169 | * Method to compute the queue thread label 170 | */ 171 | - (NSString *)queueThreadLabelForLogMessage:(DDLogMessage *)logMessage; 172 | 173 | /** 174 | * The actual method that formats a message (transforms a `DDLogMessage` model into a printable string) 175 | */ 176 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage; 177 | 178 | @end 179 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/Extensions/DDMultiFormatter.h: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | #import 17 | 18 | // Disable legacy macros 19 | #ifndef DD_LEGACY_MACROS 20 | #define DD_LEGACY_MACROS 0 21 | #endif 22 | 23 | #import "DDLog.h" 24 | 25 | /** 26 | * This formatter can be used to chain different formatters together. 27 | * The log message will processed in the order of the formatters added. 28 | **/ 29 | @interface DDMultiFormatter : NSObject 30 | 31 | /** 32 | * Array of chained formatters 33 | */ 34 | @property (readonly) NSArray *formatters; 35 | 36 | /** 37 | * Add a new formatter 38 | */ 39 | - (void)addFormatter:(id)formatter; 40 | 41 | /** 42 | * Remove a formatter 43 | */ 44 | - (void)removeFormatter:(id)formatter; 45 | 46 | /** 47 | * Remove all existing formatters 48 | */ 49 | - (void)removeAllFormatters; 50 | 51 | /** 52 | * Check if a certain formatter is used 53 | */ 54 | - (BOOL)isFormattingWithFormatter:(id)formatter; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Classes/Extensions/DDMultiFormatter.m: -------------------------------------------------------------------------------- 1 | // Software License Agreement (BSD License) 2 | // 3 | // Copyright (c) 2010-2015, Deusty, LLC 4 | // All rights reserved. 5 | // 6 | // Redistribution and use of this software in source and binary forms, 7 | // with or without modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Neither the name of Deusty nor the names of its contributors may be used 13 | // to endorse or promote products derived from this software without specific 14 | // prior written permission of Deusty, LLC. 15 | 16 | #import "DDMultiFormatter.h" 17 | 18 | 19 | #if TARGET_OS_IOS 20 | // Compiling for iOS 21 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later 22 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0 23 | #else // iOS 5.X or earlier 24 | #define NEEDS_DISPATCH_RETAIN_RELEASE 1 25 | #endif 26 | #elif TARGET_OS_WATCH || TARGET_OS_TV 27 | // Compiling for watchOS, tvOS 28 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0 29 | #else 30 | // Compiling for Mac OS X 31 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later 32 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0 33 | #else // Mac OS X 10.7 or earlier 34 | #define NEEDS_DISPATCH_RETAIN_RELEASE 1 35 | #endif 36 | #endif 37 | 38 | 39 | #if !__has_feature(objc_arc) 40 | #error This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 41 | #endif 42 | 43 | 44 | @interface DDMultiFormatter () { 45 | dispatch_queue_t _queue; 46 | NSMutableArray *_formatters; 47 | } 48 | 49 | - (DDLogMessage *)logMessageForLine:(NSString *)line originalMessage:(DDLogMessage *)message; 50 | 51 | @end 52 | 53 | 54 | @implementation DDMultiFormatter 55 | 56 | - (instancetype)init { 57 | self = [super init]; 58 | 59 | if (self) { 60 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 61 | _queue = dispatch_queue_create("cocoa.lumberjack.multiformatter", DISPATCH_QUEUE_CONCURRENT); 62 | #else 63 | _queue = dispatch_queue_create("cocoa.lumberjack.multiformatter", NULL); 64 | #endif 65 | _formatters = [NSMutableArray new]; 66 | } 67 | 68 | return self; 69 | } 70 | 71 | #if NEEDS_DISPATCH_RETAIN_RELEASE 72 | - (void)dealloc { 73 | dispatch_release(_queue); 74 | } 75 | 76 | #endif 77 | 78 | #pragma mark Processing 79 | 80 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage { 81 | __block NSString *line = logMessage->_message; 82 | 83 | dispatch_sync(_queue, ^{ 84 | for (id formatter in _formatters) { 85 | DDLogMessage *message = [self logMessageForLine:line originalMessage:logMessage]; 86 | line = [formatter formatLogMessage:message]; 87 | 88 | if (!line) { 89 | break; 90 | } 91 | } 92 | }); 93 | 94 | return line; 95 | } 96 | 97 | - (DDLogMessage *)logMessageForLine:(NSString *)line originalMessage:(DDLogMessage *)message { 98 | DDLogMessage *newMessage = [message copy]; 99 | 100 | newMessage->_message = line; 101 | return newMessage; 102 | } 103 | 104 | #pragma mark Formatters 105 | 106 | - (NSArray *)formatters { 107 | __block NSArray *formatters; 108 | 109 | dispatch_sync(_queue, ^{ 110 | formatters = [_formatters copy]; 111 | }); 112 | 113 | return formatters; 114 | } 115 | 116 | - (void)addFormatter:(id)formatter { 117 | dispatch_barrier_async(_queue, ^{ 118 | [_formatters addObject:formatter]; 119 | }); 120 | } 121 | 122 | - (void)removeFormatter:(id)formatter { 123 | dispatch_barrier_async(_queue, ^{ 124 | [_formatters removeObject:formatter]; 125 | }); 126 | } 127 | 128 | - (void)removeAllFormatters { 129 | dispatch_barrier_async(_queue, ^{ 130 | [_formatters removeAllObjects]; 131 | }); 132 | } 133 | 134 | - (BOOL)isFormattingWithFormatter:(id)formatter { 135 | __block BOOL hasFormatter; 136 | 137 | dispatch_sync(_queue, ^{ 138 | hasFormatter = [_formatters containsObject:formatter]; 139 | }); 140 | 141 | return hasFormatter; 142 | } 143 | 144 | @end 145 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/Framework/Lumberjack/CocoaLumberjack.modulemap: -------------------------------------------------------------------------------- 1 | framework module CocoaLumberjack { 2 | umbrella header "CocoaLumberjack.h" 3 | 4 | export * 5 | module * { export * } 6 | 7 | textual header "DDLogMacros.h" 8 | 9 | exclude header "DDLog+LOGV.h" 10 | exclude header "DDLegacyMacros.h" 11 | 12 | explicit module DDContextFilterLogFormatter { 13 | header "DDContextFilterLogFormatter.h" 14 | export * 15 | } 16 | 17 | explicit module DDDispatchQueueLogFormatter { 18 | header "DDDispatchQueueLogFormatter.h" 19 | export * 20 | } 21 | 22 | explicit module DDMultiFormatter { 23 | header "DDMultiFormatter.h" 24 | export * 25 | } 26 | 27 | explicit module DDASLLogCapture { 28 | header "DDASLLogCapture.h" 29 | export * 30 | } 31 | 32 | explicit module DDAbstractDatabaseLogger { 33 | header "DDAbstractDatabaseLogger.h" 34 | export * 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/CocoaLumberjack/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2010-2015, Deusty, LLC 4 | All rights reserved. 5 | 6 | Redistribution and use of this software in source and binary forms, 7 | with or without modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above 10 | copyright notice, this list of conditions and the 11 | following disclaimer. 12 | 13 | * Neither the name of Deusty nor the names of its 14 | contributors may be used to endorse or promote products 15 | derived from this software without specific prior 16 | written permission of Deusty, LLC. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/CocoaLumberjack.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/CocoaLumberjack.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDASLLogCapture.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDASLLogCapture.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDASLLogger.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDASLLogger.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDAbstractDatabaseLogger.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDAbstractDatabaseLogger.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDAssertMacros.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDAssertMacros.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDContextFilterLogFormatter.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/Extensions/DDContextFilterLogFormatter.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDDispatchQueueLogFormatter.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/Extensions/DDDispatchQueueLogFormatter.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDFileLogger.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDFileLogger.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDLegacyMacros.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDLegacyMacros.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDLog+LOGV.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDLog+LOGV.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDLog.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDLog.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDLogMacros.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDLogMacros.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDMultiFormatter.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/Extensions/DDMultiFormatter.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/CocoaLumberjack/DDTTYLogger.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDTTYLogger.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTCFSocketDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketDecoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTCFSocketEncoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketEncoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTCFSocketTransport.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketTransport.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTClient.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTClient.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTCoreDataPersistence.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTCoreDataPersistence.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTDecoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTInMemoryPersistence.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTInMemoryPersistence.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTLog.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTLog.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTMessage.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTMessage.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTPersistence.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTPersistence.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTSSLSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicy.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTSSLSecurityPolicyDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyDecoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTSSLSecurityPolicyEncoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyEncoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTSSLSecurityPolicyTransport.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyTransport.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTSession.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSession.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTSessionLegacy.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSessionLegacy.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSessionManager.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTSessionSynchron.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSessionSynchron.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTTransport.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTTransport.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/MQTTClient/MQTTWebsocketTransport.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTWebsocketTransport/MQTTWebsocketTransport.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Private/SocketRocket/SRWebSocket.h: -------------------------------------------------------------------------------- 1 | ../../../SocketRocket/SocketRocket/SRWebSocket.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/CocoaLumberjack.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/CocoaLumberjack.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDASLLogCapture.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDASLLogCapture.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDASLLogger.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDASLLogger.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDAbstractDatabaseLogger.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDAbstractDatabaseLogger.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDAssertMacros.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDAssertMacros.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDContextFilterLogFormatter.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/Extensions/DDContextFilterLogFormatter.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDDispatchQueueLogFormatter.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/Extensions/DDDispatchQueueLogFormatter.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDFileLogger.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDFileLogger.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDLegacyMacros.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDLegacyMacros.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDLog+LOGV.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDLog+LOGV.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDLog.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDLog.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDLogMacros.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDLogMacros.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDMultiFormatter.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/Extensions/DDMultiFormatter.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/CocoaLumberjack/DDTTYLogger.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaLumberjack/Classes/DDTTYLogger.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTCFSocketDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketDecoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTCFSocketEncoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketEncoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTCFSocketTransport.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketTransport.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTClient.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTClient.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTCoreDataPersistence.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTCoreDataPersistence.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTDecoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTInMemoryPersistence.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTInMemoryPersistence.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTLog.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTLog.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTMessage.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTMessage.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTPersistence.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTPersistence.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTSSLSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicy.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTSSLSecurityPolicyDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyDecoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTSSLSecurityPolicyEncoder.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyEncoder.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTSSLSecurityPolicyTransport.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyTransport.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTSession.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSession.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTSessionLegacy.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSessionLegacy.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSessionManager.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTSessionSynchron.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTSessionSynchron.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTTransport.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTTransport.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/MQTTClient/MQTTWebsocketTransport.h: -------------------------------------------------------------------------------- 1 | ../../../MQTTClient/MQTTClient/MQTTClient/MQTTWebsocketTransport/MQTTWebsocketTransport.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Headers/Public/SocketRocket/SRWebSocket.h: -------------------------------------------------------------------------------- 1 | ../../../SocketRocket/SocketRocket/SRWebSocket.h -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTCFSocketDecoder.h 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import 9 | 10 | typedef NS_ENUM(NSInteger, MQTTCFSocketDecoderState) { 11 | MQTTCFSocketDecoderStateInitializing, 12 | MQTTCFSocketDecoderStateReady, 13 | MQTTCFSocketDecoderStateError 14 | }; 15 | 16 | @class MQTTCFSocketDecoder; 17 | 18 | @protocol MQTTCFSocketDecoderDelegate 19 | - (void)decoder:(MQTTCFSocketDecoder *)sender didReceiveMessage:(NSData *)data; 20 | - (void)decoderDidOpen:(MQTTCFSocketDecoder *)sender; 21 | - (void)decoder:(MQTTCFSocketDecoder *)sender didFailWithError:(NSError *)error; 22 | - (void)decoderdidClose:(MQTTCFSocketDecoder *)sender; 23 | 24 | @end 25 | 26 | @interface MQTTCFSocketDecoder : NSObject 27 | @property (nonatomic) MQTTCFSocketDecoderState state; 28 | @property (strong, nonatomic) NSError *error; 29 | @property (strong, nonatomic) NSInputStream *stream; 30 | @property (strong, nonatomic) NSRunLoop *runLoop; 31 | @property (strong, nonatomic) NSString *runLoopMode; 32 | @property (weak, nonatomic ) id delegate; 33 | 34 | - (void)open; 35 | - (void)close; 36 | 37 | @end 38 | 39 | 40 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketDecoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTCFSocketDecoder.m 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import "MQTTCFSocketDecoder.h" 9 | 10 | #import "MQTTLog.h" 11 | 12 | @interface MQTTCFSocketDecoder() 13 | 14 | @end 15 | 16 | @implementation MQTTCFSocketDecoder 17 | 18 | - (instancetype)init { 19 | self = [super init]; 20 | self.state = MQTTCFSocketDecoderStateInitializing; 21 | 22 | self.stream = nil; 23 | self.runLoop = [NSRunLoop currentRunLoop]; 24 | self.runLoopMode = NSRunLoopCommonModes; 25 | return self; 26 | } 27 | 28 | - (void)open { 29 | if (self.state == MQTTCFSocketDecoderStateInitializing) { 30 | [self.stream setDelegate:self]; 31 | [self.stream scheduleInRunLoop:self.runLoop forMode:self.runLoopMode]; 32 | [self.stream open]; 33 | } 34 | } 35 | 36 | - (void)close { 37 | [self.stream close]; 38 | [self.stream removeFromRunLoop:self.runLoop forMode:self.runLoopMode]; 39 | [self.stream setDelegate:nil]; 40 | } 41 | 42 | - (void)stream:(NSStream*)sender handleEvent:(NSStreamEvent)eventCode { 43 | 44 | if (eventCode & NSStreamEventOpenCompleted) { 45 | DDLogVerbose(@"[MQTTCFSocketDecoder] NSStreamEventOpenCompleted"); 46 | self.state = MQTTCFSocketDecoderStateReady; 47 | [self.delegate decoderDidOpen:self]; 48 | } 49 | 50 | if (eventCode & NSStreamEventHasBytesAvailable) { 51 | DDLogVerbose(@"[MQTTCFSocketDecoder] NSStreamEventHasBytesAvailable"); 52 | if (self.state == MQTTCFSocketDecoderStateInitializing) { 53 | self.state = MQTTCFSocketDecoderStateReady; 54 | } 55 | 56 | if (self.state == MQTTCFSocketDecoderStateReady) { 57 | NSInteger n; 58 | UInt8 buffer[768]; 59 | 60 | n = [self.stream read:buffer maxLength:sizeof(buffer)]; 61 | if (n == -1) { 62 | self.state = MQTTCFSocketDecoderStateError; 63 | [self.delegate decoder:self didFailWithError:nil]; 64 | } else { 65 | NSData *data = [NSData dataWithBytes:buffer length:n]; 66 | DDLogVerbose(@"[MQTTCFSocketDecoder] received (%lu)=%@...", (unsigned long)data.length, 67 | [data subdataWithRange:NSMakeRange(0, MIN(256, data.length))]); 68 | [self.delegate decoder:self didReceiveMessage:data]; 69 | } 70 | } 71 | } 72 | if (eventCode & NSStreamEventHasSpaceAvailable) { 73 | DDLogVerbose(@"[MQTTCFSocketDecoder] NSStreamEventHasSpaceAvailable"); 74 | } 75 | 76 | if (eventCode & NSStreamEventEndEncountered) { 77 | DDLogVerbose(@"[MQTTCFSocketDecoder] NSStreamEventEndEncountered"); 78 | self.state = MQTTCFSocketDecoderStateInitializing; 79 | self.error = nil; 80 | [self.delegate decoderdidClose:self]; 81 | } 82 | 83 | if (eventCode & NSStreamEventErrorOccurred) { 84 | DDLogVerbose(@"[MQTTCFSocketDecoder] NSStreamEventErrorOccurred"); 85 | self.state = MQTTCFSocketDecoderStateError; 86 | self.error = self.stream.streamError; 87 | [self.delegate decoder:self didFailWithError:self.error]; 88 | } 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTCFSocketEncoder.h 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import 9 | 10 | typedef NS_ENUM(NSInteger, MQTTCFSocketEncoderState) { 11 | MQTTCFSocketEncoderStateInitializing, 12 | MQTTCFSocketEncoderStateReady, 13 | MQTTCFSocketEncoderStateError 14 | }; 15 | 16 | @class MQTTCFSocketEncoder; 17 | 18 | @protocol MQTTCFSocketEncoderDelegate 19 | - (void)encoderDidOpen:(MQTTCFSocketEncoder *)sender; 20 | - (void)encoder:(MQTTCFSocketEncoder *)sender didFailWithError:(NSError *)error; 21 | - (void)encoderdidClose:(MQTTCFSocketEncoder *)sender; 22 | 23 | @end 24 | 25 | @interface MQTTCFSocketEncoder : NSObject 26 | @property (nonatomic) MQTTCFSocketEncoderState state; 27 | @property (strong, nonatomic) NSError *error; 28 | @property (strong, nonatomic) NSOutputStream *stream; 29 | @property (strong, nonatomic) NSRunLoop *runLoop; 30 | @property (strong, nonatomic) NSString *runLoopMode; 31 | @property (weak, nonatomic ) id delegate; 32 | 33 | - (void)open; 34 | - (void)close; 35 | - (BOOL)send:(NSData *)data; 36 | 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketEncoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTCFSocketEncoder.m 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import "MQTTCFSocketEncoder.h" 9 | 10 | #import "MQTTLog.h" 11 | 12 | @interface MQTTCFSocketEncoder() 13 | @property (strong, nonatomic) NSMutableData *buffer; 14 | 15 | @end 16 | 17 | @implementation MQTTCFSocketEncoder 18 | 19 | - (instancetype)init { 20 | self = [super init]; 21 | self.state = MQTTCFSocketEncoderStateInitializing; 22 | self.buffer = [[NSMutableData alloc] init]; 23 | 24 | self.stream = nil; 25 | self.runLoop = [NSRunLoop currentRunLoop]; 26 | self.runLoopMode = NSRunLoopCommonModes; 27 | 28 | return self; 29 | } 30 | 31 | - (void)open { 32 | [self.stream setDelegate:self]; 33 | [self.stream scheduleInRunLoop:self.runLoop forMode:self.runLoopMode]; 34 | [self.stream open]; 35 | } 36 | 37 | - (void)close { 38 | [self.stream close]; 39 | [self.stream removeFromRunLoop:self.runLoop forMode:self.runLoopMode]; 40 | [self.stream setDelegate:nil]; 41 | } 42 | 43 | - (void)setState:(MQTTCFSocketEncoderState)state { 44 | DDLogVerbose(@"[MQTTCFSocketEncoder] setState %ld/%ld", (long)_state, (long)state); 45 | _state = state; 46 | } 47 | 48 | - (void)stream:(NSStream*)sender handleEvent:(NSStreamEvent)eventCode { 49 | 50 | if (eventCode & NSStreamEventOpenCompleted) { 51 | DDLogVerbose(@"[MQTTCFSocketEncoder] NSStreamEventOpenCompleted"); 52 | 53 | } 54 | if (eventCode & NSStreamEventHasBytesAvailable) { 55 | DDLogVerbose(@"[MQTTCFSocketEncoder] NSStreamEventHasBytesAvailable"); 56 | } 57 | 58 | if (eventCode & NSStreamEventHasSpaceAvailable) { 59 | DDLogVerbose(@"[MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable"); 60 | if (self.state == MQTTCFSocketEncoderStateInitializing) { 61 | self.state = MQTTCFSocketEncoderStateReady; 62 | [self.delegate encoderDidOpen:self]; 63 | } 64 | 65 | if (self.state == MQTTCFSocketEncoderStateReady) { 66 | if (self.buffer.length) { 67 | [self send:nil]; 68 | } 69 | } 70 | } 71 | 72 | if (eventCode & NSStreamEventEndEncountered) { 73 | DDLogVerbose(@"[MQTTCFSocketEncoder] NSStreamEventEndEncountered"); 74 | self.state = MQTTCFSocketEncoderStateInitializing; 75 | self.error = nil; 76 | [self.delegate encoderdidClose:self]; 77 | } 78 | 79 | if (eventCode & NSStreamEventErrorOccurred) { 80 | DDLogVerbose(@"[MQTTCFSocketEncoder] NSStreamEventErrorOccurred"); 81 | self.state = MQTTCFSocketEncoderStateError; 82 | self.error = self.stream.streamError; 83 | [self.delegate encoder:self didFailWithError:self.error]; 84 | } 85 | } 86 | 87 | - (BOOL)send:(NSData *)data { 88 | @synchronized(self) { 89 | if (self.state != MQTTCFSocketEncoderStateReady) { 90 | DDLogInfo(@"[MQTTCFSocketEncoder] not MQTTCFSocketEncoderStateReady"); 91 | return FALSE; 92 | } 93 | 94 | if (data) { 95 | [self.buffer appendData:data]; 96 | } 97 | 98 | if (self.buffer.length) { 99 | DDLogVerbose(@"[MQTTCFSocketEncoder] buffer to write (%lu)=%@...", 100 | (unsigned long)self.buffer.length, 101 | [self.buffer subdataWithRange:NSMakeRange(0, MIN(256, self.buffer.length))]); 102 | 103 | NSInteger n = [self.stream write:self.buffer.bytes maxLength:self.buffer.length]; 104 | 105 | if (n == -1) { 106 | DDLogVerbose(@"[MQTTCFSocketEncoder] streamError: %@", self.error); 107 | self.state = MQTTCFSocketEncoderStateError; 108 | self.error = self.stream.streamError; 109 | return FALSE; 110 | } else { 111 | if (n < self.buffer.length) { 112 | DDLogVerbose(@"[MQTTCFSocketEncoder] buffer partially written: %ld", (long)n); 113 | } 114 | [self.buffer replaceBytesInRange:NSMakeRange(0, n) withBytes:NULL length:0]; 115 | } 116 | } 117 | return TRUE; 118 | } 119 | } 120 | 121 | @end -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketTransport.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTCFSocketTransport.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 06.12.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import "MQTTTransport.h" 10 | #import "MQTTCFSocketDecoder.h" 11 | #import "MQTTCFSocketEncoder.h" 12 | 13 | /** MQTTCFSocketTransport 14 | * implements an MQTTTransport on top of CFNetwork 15 | */ 16 | @interface MQTTCFSocketTransport : MQTTTransport 17 | 18 | /** host an NSString containing the hostName or IP address of the host to connect to 19 | * defaults to @"localhost" 20 | */ 21 | @property (strong, nonatomic) NSString *host; 22 | 23 | /** port an unsigned 16 bit integer containing the IP port number to connect to 24 | * defaults to 1883 25 | */ 26 | @property (nonatomic) UInt16 port; 27 | 28 | /** tls a boolean indicating whether the transport should be using security 29 | * defaults to NO 30 | */ 31 | @property (nonatomic) BOOL tls; 32 | 33 | /** certificates An identity certificate used to reply to a server requiring client certificates according 34 | * to the description given for SSLSetCertificate(). You may build the certificates array yourself or use the 35 | * sundry method clientCertFromP12. 36 | */ 37 | @property (strong, nonatomic) NSArray *certificates; 38 | 39 | /** reads the content of a PKCS12 file and converts it to an certificates array for initWith... 40 | @param path the path to a PKCS12 file 41 | @param passphrase the passphrase to unlock the PKCS12 file 42 | @returns a certificates array or nil if an error occured 43 | 44 | @code 45 | NSString *path = [[NSBundle bundleForClass:[MQTTClientTests class]] pathForResource:@"filename" 46 | ofType:@"p12"]; 47 | 48 | NSArray *myCerts = [MQTTCFSocketTransport clientCertsFromP12:path passphrase:@"passphrase"]; 49 | if (myCerts) { 50 | 51 | self.session = [[MQTTSession alloc] init]; 52 | ... 53 | self.session.certificates = myCerts; 54 | 55 | [self.session connect]; 56 | ... 57 | } 58 | 59 | @endcode 60 | 61 | */ 62 | 63 | + (NSArray *)clientCertsFromP12:(NSString *)path passphrase:(NSString *)passphrase; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTCFSocketTransport.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTCFSocketTransport.m 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 06.12.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import "MQTTCFSocketTransport.h" 10 | 11 | #import "MQTTLog.h" 12 | 13 | @interface MQTTCFSocketTransport() 14 | @property (strong, nonatomic) MQTTCFSocketEncoder *encoder; 15 | @property (strong, nonatomic) MQTTCFSocketDecoder *decoder; 16 | @end 17 | 18 | @implementation MQTTCFSocketTransport 19 | @synthesize state; 20 | @synthesize delegate; 21 | @synthesize runLoop; 22 | @synthesize runLoopMode; 23 | 24 | - (instancetype)init { 25 | self = [super init]; 26 | self.host = @"localhost"; 27 | self.port = 1883; 28 | self.tls = false; 29 | self.certificates = nil; 30 | return self; 31 | } 32 | 33 | - (void)open { 34 | DDLogVerbose(@"[MQTTCFSocketTransport] open"); 35 | self.state = MQTTTransportOpening; 36 | 37 | NSError* connectError; 38 | 39 | CFReadStreamRef readStream; 40 | CFWriteStreamRef writeStream; 41 | 42 | CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)self.host, self.port, &readStream, &writeStream); 43 | 44 | CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); 45 | CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); 46 | 47 | if (self.tls) { 48 | NSMutableDictionary *sslOptions = [[NSMutableDictionary alloc] init]; 49 | 50 | [sslOptions setObject:(NSString *)kCFStreamSocketSecurityLevelNegotiatedSSL 51 | forKey:(NSString*)kCFStreamSSLLevel]; 52 | 53 | if (self.certificates) { 54 | [sslOptions setObject:self.certificates 55 | forKey:(NSString *)kCFStreamSSLCertificates]; 56 | } 57 | 58 | if(!CFReadStreamSetProperty(readStream, kCFStreamPropertySSLSettings, (__bridge CFDictionaryRef)(sslOptions))){ 59 | connectError = [NSError errorWithDomain:@"MQTT" 60 | code:errSSLInternal 61 | userInfo:@{NSLocalizedDescriptionKey : @"Fail to init ssl input stream!"}]; 62 | } 63 | if(!CFWriteStreamSetProperty(writeStream, kCFStreamPropertySSLSettings, (__bridge CFDictionaryRef)(sslOptions))){ 64 | connectError = [NSError errorWithDomain:@"MQTT" 65 | code:errSSLInternal 66 | userInfo:@{NSLocalizedDescriptionKey : @"Fail to init ssl output stream!"}]; 67 | } 68 | } 69 | 70 | if(!connectError){ 71 | self.encoder = [[MQTTCFSocketEncoder alloc] init]; 72 | self.encoder.stream = CFBridgingRelease(writeStream); 73 | self.encoder.runLoop = self.runLoop; 74 | self.encoder.runLoopMode = self.runLoopMode; 75 | self.encoder.delegate = self; 76 | [self.encoder open]; 77 | 78 | self.decoder = [[MQTTCFSocketDecoder alloc] init]; 79 | self.decoder.stream = CFBridgingRelease(readStream); 80 | self.decoder.runLoop = self.runLoop; 81 | self.decoder.runLoopMode = self.runLoopMode; 82 | self.decoder.delegate = self; 83 | [self.decoder open]; 84 | 85 | } else { 86 | [self close]; 87 | } 88 | } 89 | 90 | - (void)close { 91 | DDLogVerbose(@"[MQTTCFSocketTransport] close"); 92 | self.state = MQTTTransportClosing; 93 | 94 | if (self.encoder) { 95 | [self.encoder close]; 96 | self.encoder.delegate = nil; 97 | } 98 | 99 | if (self.decoder) { 100 | [self.decoder close]; 101 | self.decoder.delegate = nil; 102 | } 103 | } 104 | 105 | - (BOOL)send:(nonnull NSData *)data { 106 | return [self.encoder send:data]; 107 | } 108 | 109 | - (void)decoder:(MQTTCFSocketDecoder *)sender didReceiveMessage:(nonnull NSData *)data { 110 | [self.delegate mqttTransport:self didReceiveMessage:data]; 111 | } 112 | 113 | - (void)decoder:(MQTTCFSocketDecoder *)sender didFailWithError:(NSError *)error { 114 | //self.state = MQTTTransportClosing; 115 | //[self.delegate mqttTransport:self didFailWithError:error]; 116 | } 117 | - (void)encoder:(MQTTCFSocketEncoder *)sender didFailWithError:(NSError *)error { 118 | self.state = MQTTTransportClosing; 119 | [self.delegate mqttTransport:self didFailWithError:error]; 120 | } 121 | 122 | - (void)decoderdidClose:(MQTTCFSocketDecoder *)sender { 123 | self.state = MQTTTransportClosed; 124 | [self.delegate mqttTransportDidClose:self]; 125 | } 126 | - (void)encoderdidClose:(MQTTCFSocketEncoder *)sender { 127 | //self.state = MQTTTransportClosed; 128 | //[self.delegate mqttTransportDidClose:self]; 129 | } 130 | 131 | - (void)decoderDidOpen:(MQTTCFSocketDecoder *)sender { 132 | //self.state = MQTTTransportOpen; 133 | //[self.delegate mqttTransportDidOpen:self]; 134 | } 135 | - (void)encoderDidOpen:(MQTTCFSocketEncoder *)sender { 136 | self.state = MQTTTransportOpen; 137 | [self.delegate mqttTransportDidOpen:self]; 138 | } 139 | 140 | + (NSArray *)clientCertsFromP12:(NSString *)path passphrase:(NSString *)passphrase { 141 | if (!path) { 142 | DDLogWarn(@"[MQTTCFSocketTransport] no p12 path given"); 143 | return nil; 144 | } 145 | 146 | NSData *pkcs12data = [[NSData alloc] initWithContentsOfFile:path]; 147 | if (!pkcs12data) { 148 | DDLogWarn(@"[MQTTCFSocketTransport] reading p12 failed"); 149 | return nil; 150 | } 151 | 152 | if (!passphrase) { 153 | DDLogWarn(@"[MQTTCFSocketTransport] no passphrase given"); 154 | return nil; 155 | } 156 | CFArrayRef keyref = NULL; 157 | OSStatus importStatus = SecPKCS12Import((__bridge CFDataRef)pkcs12data, 158 | (__bridge CFDictionaryRef)[NSDictionary 159 | dictionaryWithObject:passphrase 160 | forKey:(__bridge id)kSecImportExportPassphrase], 161 | &keyref); 162 | if (importStatus != noErr) { 163 | DDLogWarn(@"[MQTTCFSocketTransport] Error while importing pkcs12 [%d]", (int)importStatus); 164 | return nil; 165 | } 166 | 167 | CFDictionaryRef identityDict = CFArrayGetValueAtIndex(keyref, 0); 168 | if (!identityDict) { 169 | DDLogWarn(@"[MQTTCFSocketTransport] could not CFArrayGetValueAtIndex"); 170 | return nil; 171 | } 172 | 173 | SecIdentityRef identityRef = (SecIdentityRef)CFDictionaryGetValue(identityDict, 174 | kSecImportItemIdentity); 175 | if (!identityRef) { 176 | DDLogWarn(@"[MQTTCFSocketTransport] could not CFDictionaryGetValue"); 177 | return nil; 178 | }; 179 | 180 | SecCertificateRef cert = NULL; 181 | OSStatus status = SecIdentityCopyCertificate(identityRef, &cert); 182 | if (status != noErr) { 183 | DDLogWarn(@"[MQTTCFSocketTransport] SecIdentityCopyCertificate failed [%d]", (int)status); 184 | return nil; 185 | } 186 | 187 | NSArray *clientCerts = [[NSArray alloc] initWithObjects:(__bridge id)identityRef, (__bridge id)cert, nil]; 188 | return clientCerts; 189 | } 190 | 191 | @end 192 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTClient.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 13.01.14. 6 | // Copyright © 2013-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | /** 10 | Include this file to use MQTTClient classes in your application 11 | 12 | @author Christoph Krey krey.christoph@gmail.com 13 | @see http://mqtt.org 14 | */ 15 | 16 | #import 17 | 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTCoreDataPersistence.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTCoreDataPersistence.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 22.03.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "MQTTPersistence.h" 12 | 13 | @interface MQTTCoreDataPersistence : NSObject 14 | 15 | @end 16 | 17 | @interface MQTTFlow : NSManagedObject 18 | @end 19 | 20 | @interface MQTTCoreDataFlow : NSObject 21 | @end 22 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTDecoder.h 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | // based on 8 | // 9 | // Copyright (c) 2011, 2013, 2lemetry LLC 10 | // 11 | // All rights reserved. This program and the accompanying materials 12 | // are made available under the terms of the Eclipse Public License v1.0 13 | // which accompanies this distribution, and is available at 14 | // http://www.eclipse.org/legal/epl-v10.html 15 | // 16 | // Contributors: 17 | // Kyle Roche - initial API and implementation and/or initial documentation 18 | // 19 | 20 | #import 21 | #import "MQTTMessage.h" 22 | 23 | typedef enum { 24 | MQTTDecoderEventProtocolError, 25 | MQTTDecoderEventConnectionClosed, 26 | MQTTDecoderEventConnectionError 27 | } MQTTDecoderEvent; 28 | 29 | typedef enum { 30 | MQTTDecoderStateInitializing, 31 | MQTTDecoderStateDecodingHeader, 32 | MQTTDecoderStateDecodingLength, 33 | MQTTDecoderStateDecodingData, 34 | MQTTDecoderStateConnectionClosed, 35 | MQTTDecoderStateConnectionError, 36 | MQTTDecoderStateProtocolError 37 | } MQTTDecoderState; 38 | 39 | @class MQTTDecoder; 40 | 41 | @protocol MQTTDecoderDelegate 42 | 43 | - (void)decoder:(MQTTDecoder *)sender didReceiveMessage:(NSData *)data; 44 | - (void)decoder:(MQTTDecoder *)sender handleEvent:(MQTTDecoderEvent)eventCode error:(NSError *)error; 45 | 46 | @end 47 | 48 | 49 | @interface MQTTDecoder : NSObject 50 | @property (nonatomic) MQTTDecoderState state; 51 | @property (strong, nonatomic) NSRunLoop* runLoop; 52 | @property (strong, nonatomic) NSString* runLoopMode; 53 | @property (nonatomic) UInt32 length; 54 | @property (nonatomic) UInt32 lengthMultiplier; 55 | @property (nonatomic) int offset; 56 | @property (strong, nonatomic) NSMutableData* dataBuffer; 57 | 58 | @property (weak, nonatomic ) id delegate; 59 | 60 | - (void)open; 61 | - (void)close; 62 | - (void)decodeMessage:(NSData *)data; 63 | @end 64 | 65 | 66 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTDecoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTDecoder.m 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import "MQTTDecoder.h" 9 | 10 | #import "MQTTLog.h" 11 | 12 | @interface MQTTDecoder() 13 | @property (nonatomic) NSMutableArray *streams; 14 | @end 15 | 16 | @implementation MQTTDecoder 17 | 18 | - (instancetype)init { 19 | self = [super init]; 20 | self.state = MQTTDecoderStateInitializing; 21 | self.runLoop = [NSRunLoop currentRunLoop]; 22 | self.runLoopMode = NSRunLoopCommonModes; 23 | self.streams = [NSMutableArray arrayWithCapacity:5]; 24 | return self; 25 | } 26 | 27 | - (void)decodeMessage:(NSData *)data { 28 | NSInputStream *stream = [NSInputStream inputStreamWithData:data]; 29 | [self openStream:stream]; 30 | } 31 | 32 | - (void)openStream:(NSInputStream*)stream { 33 | [self.streams addObject:stream]; 34 | [stream setDelegate:self]; 35 | DDLogVerbose(@"[MQTTDecoder] #streams=%lu", (unsigned long)self.streams.count); 36 | if (self.streams.count == 1) { 37 | [stream scheduleInRunLoop:self.runLoop forMode:self.runLoopMode]; 38 | [stream open]; 39 | } 40 | } 41 | 42 | - (void)open { 43 | self.state = MQTTDecoderStateDecodingHeader; 44 | } 45 | 46 | - (void)close { 47 | if (self.streams) { 48 | for (NSInputStream *stream in self.streams) { 49 | [stream close]; 50 | [stream removeFromRunLoop:self.runLoop forMode:self.runLoopMode]; 51 | [stream setDelegate:nil]; 52 | } 53 | [self.streams removeAllObjects]; 54 | } 55 | } 56 | 57 | - (void)stream:(NSStream*)sender handleEvent:(NSStreamEvent)eventCode { 58 | NSInputStream *stream = (NSInputStream *)sender; 59 | 60 | if (eventCode & NSStreamEventOpenCompleted) { 61 | DDLogVerbose(@"[MQTTDecoder] NSStreamEventOpenCompleted"); 62 | } 63 | 64 | if (eventCode & NSStreamEventHasBytesAvailable) { 65 | DDLogVerbose(@"[MQTTDecoder] NSStreamEventHasBytesAvailable"); 66 | 67 | if (self.state == MQTTDecoderStateDecodingHeader) { 68 | UInt8 buffer; 69 | NSInteger n = [stream read:&buffer maxLength:1]; 70 | if (n == -1) { 71 | self.state = MQTTDecoderStateConnectionError; 72 | [self.delegate decoder:self handleEvent:MQTTDecoderEventConnectionError error:stream.streamError]; 73 | } else if (n == 1) { 74 | self.length = 0; 75 | self.lengthMultiplier = 1; 76 | self.state = MQTTDecoderStateDecodingLength; 77 | self.dataBuffer = [[NSMutableData alloc] init]; 78 | [self.dataBuffer appendBytes:&buffer length:1]; 79 | self.offset = 1; 80 | DDLogVerbose(@"[MQTTDecoder] fixedHeader=0x%02x", buffer); 81 | } 82 | } 83 | while (self.state == MQTTDecoderStateDecodingLength) { 84 | // TODO: check max packet length(prevent evil server response) 85 | UInt8 digit; 86 | NSInteger n = [stream read:&digit maxLength:1]; 87 | if (n == -1) { 88 | self.state = MQTTDecoderStateConnectionError; 89 | [self.delegate decoder:self handleEvent:MQTTDecoderEventConnectionError error:stream.streamError]; 90 | break; 91 | } else if (n == 0) { 92 | break; 93 | } 94 | DDLogVerbose(@"[MQTTDecoder] digit=0x%02x 0x%02x %d %d", digit, digit & 0x7f, (unsigned int)self.length, (unsigned int)self.lengthMultiplier); 95 | [self.dataBuffer appendBytes:&digit length:1]; 96 | self.offset++; 97 | self.length += ((digit & 0x7f) * self.lengthMultiplier); 98 | if ((digit & 0x80) == 0x00) { 99 | self.state = MQTTDecoderStateDecodingData; 100 | } else { 101 | self.lengthMultiplier *= 128; 102 | } 103 | } 104 | DDLogVerbose(@"[MQTTDecoder] remainingLength=%d", (unsigned int)self.length); 105 | 106 | if (self.state == MQTTDecoderStateDecodingData) { 107 | if (self.length > 0) { 108 | NSInteger n, toRead; 109 | UInt8 buffer[768]; 110 | toRead = self.length + self.offset - self.dataBuffer.length; 111 | if (toRead > sizeof buffer) { 112 | toRead = sizeof buffer; 113 | } 114 | n = [stream read:buffer maxLength:toRead]; 115 | if (n == -1) { 116 | self.state = MQTTDecoderStateConnectionError; 117 | [self.delegate decoder:self handleEvent:MQTTDecoderEventConnectionError error:stream.streamError]; 118 | } else { 119 | DDLogVerbose(@"[MQTTDecoder] read %ld %ld", (long)toRead, (long)n); 120 | [self.dataBuffer appendBytes:buffer length:n]; 121 | } 122 | } 123 | if (self.dataBuffer.length == self.length + self.offset) { 124 | DDLogVerbose(@"[MQTTDecoder] received (%lu)=%@...", (unsigned long)self.dataBuffer.length, 125 | [self.dataBuffer subdataWithRange:NSMakeRange(0, MIN(256, self.dataBuffer.length))]); 126 | [self.delegate decoder:self didReceiveMessage:self.dataBuffer]; 127 | self.dataBuffer = nil; 128 | self.state = MQTTDecoderStateDecodingHeader; 129 | } 130 | } 131 | } 132 | 133 | if (eventCode & NSStreamEventHasSpaceAvailable) { 134 | DDLogVerbose(@"[MQTTDecoder] NSStreamEventHasSpaceAvailable"); 135 | } 136 | 137 | if (eventCode & NSStreamEventEndEncountered) { 138 | DDLogVerbose(@"[MQTTDecoder] NSStreamEventEndEncountered"); 139 | 140 | if (self.streams) { 141 | [self.streams removeObject:stream]; 142 | if (self.streams.count) { 143 | NSInputStream *stream = [self.streams objectAtIndex:0]; 144 | [stream scheduleInRunLoop:self.runLoop forMode:self.runLoopMode]; 145 | [stream open]; 146 | } 147 | } 148 | } 149 | 150 | if (eventCode & NSStreamEventErrorOccurred) { 151 | DDLogVerbose(@"[MQTTDecoder] NSStreamEventErrorOccurred"); 152 | 153 | self.state = MQTTDecoderStateConnectionError; 154 | NSError *error = [stream streamError]; 155 | if (self.streams) { 156 | [self.streams removeObject:stream]; 157 | if (self.streams.count) { 158 | NSInputStream *stream = [self.streams objectAtIndex:0]; 159 | [stream scheduleInRunLoop:self.runLoop forMode:self.runLoopMode]; 160 | [stream open]; 161 | } 162 | } 163 | [self.delegate decoder:self handleEvent:MQTTDecoderEventConnectionError error:error]; 164 | } 165 | } 166 | 167 | @end 168 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTInMemoryPersistence.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTInMemoryPersistence.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 22.03.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MQTTPersistence.h" 11 | 12 | @interface MQTTInMemoryPersistence : NSObject 13 | @end 14 | 15 | @interface MQTTInMemoryFlow : NSObject 16 | @end 17 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTInMemoryPersistence.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTInMemoryPersistence.m 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 22.03.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import "MQTTInMemoryPersistence.h" 10 | 11 | #import "MQTTLog.h" 12 | 13 | @implementation MQTTInMemoryFlow 14 | @synthesize clientId; 15 | @synthesize incomingFlag; 16 | @synthesize retainedFlag; 17 | @synthesize commandType; 18 | @synthesize qosLevel; 19 | @synthesize messageId; 20 | @synthesize topic; 21 | @synthesize data; 22 | @synthesize deadline; 23 | 24 | @end 25 | 26 | @interface MQTTInMemoryPersistence() 27 | @end 28 | 29 | static NSMutableDictionary *clientIds; 30 | 31 | @implementation MQTTInMemoryPersistence 32 | @synthesize maxSize; 33 | @synthesize persistent; 34 | @synthesize maxMessages; 35 | @synthesize maxWindowSize; 36 | 37 | - (MQTTInMemoryPersistence *)init { 38 | self = [super init]; 39 | self.maxMessages = MQTT_MAX_MESSAGES; 40 | self.maxWindowSize = MQTT_MAX_WINDOW_SIZE; 41 | @synchronized(clientIds) { 42 | if (!clientIds) { 43 | clientIds = [[NSMutableDictionary alloc] init]; 44 | } 45 | } 46 | return self; 47 | } 48 | 49 | - (NSUInteger)windowSize:(NSString *)clientId { 50 | NSUInteger windowSize = 0; 51 | NSArray *flows = [self allFlowsforClientId:clientId 52 | incomingFlag:NO]; 53 | for (MQTTInMemoryFlow *flow in flows) { 54 | if ([flow.commandType intValue] != MQTT_None) { 55 | windowSize++; 56 | } 57 | } 58 | return windowSize; 59 | } 60 | 61 | - (MQTTInMemoryFlow *)storeMessageForClientId:(NSString *)clientId 62 | topic:(NSString *)topic 63 | data:(NSData *)data 64 | retainFlag:(BOOL)retainFlag 65 | qos:(MQTTQosLevel)qos 66 | msgId:(UInt16)msgId 67 | incomingFlag:(BOOL)incomingFlag 68 | commandType:(UInt8)commandType 69 | deadline:(NSDate *)deadline { 70 | @synchronized(clientIds) { 71 | 72 | if (([self allFlowsforClientId:clientId incomingFlag:incomingFlag].count <= self.maxMessages)) { 73 | MQTTInMemoryFlow *flow = (MQTTInMemoryFlow *)[self createFlowforClientId:clientId 74 | incomingFlag:incomingFlag 75 | messageId:msgId]; 76 | flow.topic = topic; 77 | flow.data = data; 78 | flow.retainedFlag = [NSNumber numberWithBool:retainFlag]; 79 | flow.qosLevel = [NSNumber numberWithUnsignedInteger:qos]; 80 | flow.commandType = [NSNumber numberWithUnsignedInteger:commandType]; 81 | flow.deadline = deadline; 82 | return flow; 83 | } else { 84 | return nil; 85 | } 86 | } 87 | } 88 | 89 | - (void)deleteFlow:(MQTTInMemoryFlow *)flow { 90 | @synchronized(clientIds) { 91 | 92 | NSMutableDictionary *clientIdFlows = [clientIds objectForKey:flow.clientId]; 93 | if (clientIdFlows) { 94 | NSMutableDictionary *clientIdDirectedFlow = [clientIdFlows objectForKey:flow.incomingFlag]; 95 | if (clientIdDirectedFlow) { 96 | [clientIdDirectedFlow removeObjectForKey:flow.messageId]; 97 | } 98 | } 99 | } 100 | } 101 | 102 | - (void)deleteAllFlowsForClientId:(NSString *)clientId { 103 | @synchronized(clientIds) { 104 | 105 | DDLogInfo(@"[MQTTInMemoryPersistence] deleteAllFlowsForClientId %@", clientId); 106 | [clientIds removeObjectForKey:clientId]; 107 | } 108 | } 109 | 110 | - (void)sync { 111 | // 112 | } 113 | 114 | - (NSArray *)allFlowsforClientId:(NSString *)clientId 115 | incomingFlag:(BOOL)incomingFlag { 116 | @synchronized(clientIds) { 117 | 118 | NSArray *flows = nil; 119 | NSMutableDictionary *clientIdFlows = [clientIds objectForKey:clientId]; 120 | if (clientIdFlows) { 121 | NSMutableDictionary *clientIdDirectedFlow = [clientIdFlows objectForKey:[NSNumber numberWithBool:incomingFlag]]; 122 | if (clientIdDirectedFlow) { 123 | flows = clientIdDirectedFlow.allValues; 124 | } 125 | } 126 | return flows; 127 | } 128 | } 129 | 130 | - (MQTTInMemoryFlow *)flowforClientId:(NSString *)clientId 131 | incomingFlag:(BOOL)incomingFlag 132 | messageId:(UInt16)messageId { 133 | @synchronized(clientIds) { 134 | 135 | MQTTInMemoryFlow *flow = nil; 136 | 137 | NSMutableDictionary *clientIdFlows = [clientIds objectForKey:clientId]; 138 | if (clientIdFlows) { 139 | NSMutableDictionary *clientIdDirectedFlow = [clientIdFlows objectForKey:[NSNumber numberWithBool:incomingFlag]]; 140 | if (clientIdDirectedFlow) { 141 | flow = [clientIdDirectedFlow objectForKey:[NSNumber numberWithUnsignedInteger:messageId]]; 142 | } 143 | } 144 | 145 | return flow; 146 | } 147 | } 148 | 149 | - (MQTTInMemoryFlow *)createFlowforClientId:(NSString *)clientId 150 | incomingFlag:(BOOL)incomingFlag 151 | messageId:(UInt16)messageId { 152 | @synchronized(clientIds) { 153 | NSMutableDictionary *clientIdFlows = [clientIds objectForKey:clientId]; 154 | if (!clientIdFlows) { 155 | clientIdFlows = [[NSMutableDictionary alloc] init]; 156 | [clientIds setObject:clientIdFlows forKey:clientId]; 157 | } 158 | 159 | NSMutableDictionary *clientIdDirectedFlow = [clientIdFlows objectForKey:[NSNumber numberWithBool:incomingFlag]]; 160 | if (!clientIdDirectedFlow) { 161 | clientIdDirectedFlow = [[NSMutableDictionary alloc] init]; 162 | [clientIdFlows setObject:clientIdDirectedFlow forKey:[NSNumber numberWithBool:incomingFlag]]; 163 | } 164 | 165 | MQTTInMemoryFlow *flow = [[MQTTInMemoryFlow alloc] init]; 166 | flow.clientId = clientId; 167 | flow.incomingFlag = [NSNumber numberWithBool:incomingFlag]; 168 | flow.messageId = [NSNumber numberWithUnsignedInteger:messageId]; 169 | 170 | [clientIdDirectedFlow setObject:flow forKey:[NSNumber numberWithUnsignedInteger:messageId]]; 171 | 172 | return flow; 173 | } 174 | } 175 | 176 | @end 177 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTLog.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTLog.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 10.02.16. 6 | // Copyright © 2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #ifndef MQTTLog_h 10 | 11 | #define MQTTLog_h 12 | 13 | 14 | #ifdef LUMBERJACK 15 | #define LOG_LEVEL_DEF ddLogLevel 16 | #import 17 | #ifndef myLogLevel 18 | #ifdef DEBUG 19 | static const DDLogLevel ddLogLevel = DDLogLevelWarning; 20 | #else 21 | static const DDLogLevel ddLogLevel = DDLogLevelWarning; 22 | #endif 23 | #else 24 | static const DDLogLevel ddLogLevel = myLogLevel; 25 | #endif 26 | #else 27 | #ifdef DEBUG 28 | #define DDLogVerbose NSLog 29 | #define DDLogWarn NSLog 30 | #define DDLogInfo NSLog 31 | #define DDLogError NSLog 32 | #else 33 | #define DDLogVerbose(...) 34 | #define DDLogWarn(...) 35 | #define DDLogInfo(...) 36 | #define DDLogError(...) 37 | #endif 38 | #endif 39 | 40 | 41 | #endif /* MQTTLog_h */ 42 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTMessage.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTMessage.h 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | // based on 8 | // 9 | // Copyright (c) 2011, 2013, 2lemetry LLC 10 | // 11 | // All rights reserved. This program and the accompanying materials 12 | // are made available under the terms of the Eclipse Public License v1.0 13 | // which accompanies this distribution, and is available at 14 | // http://www.eclipse.org/legal/epl-v10.html 15 | // 16 | // Contributors: 17 | // Kyle Roche - initial API and implementation and/or initial documentation 18 | // 19 | 20 | #import 21 | 22 | @interface MQTTMessage : NSObject 23 | typedef NS_ENUM(UInt8, MQTTCommandType) { 24 | MQTT_None = 0, 25 | MQTTConnect = 1, 26 | MQTTConnack = 2, 27 | MQTTPublish = 3, 28 | MQTTPuback = 4, 29 | MQTTPubrec = 5, 30 | MQTTPubrel = 6, 31 | MQTTPubcomp = 7, 32 | MQTTSubscribe = 8, 33 | MQTTSuback = 9, 34 | MQTTUnsubscribe = 10, 35 | MQTTUnsuback = 11, 36 | MQTTPingreq = 12, 37 | MQTTPingresp = 13, 38 | MQTTDisconnect = 14 39 | }; 40 | 41 | /** 42 | Enumeration of MQTT Quality of Service levels 43 | */ 44 | typedef NS_ENUM(UInt8, MQTTQosLevel) { 45 | MQTTQosLevelAtMostOnce = 0, 46 | MQTTQosLevelAtLeastOnce = 1, 47 | MQTTQosLevelExactlyOnce = 2 48 | }; 49 | 50 | /** 51 | Enumeration of MQTT protocol version 52 | */ 53 | typedef NS_ENUM(UInt8, MQTTProtocolVersion) { 54 | MQTTProtocolVersion31 = 3, 55 | MQTTProtocolVersion311 = 4 56 | }; 57 | 58 | @property (nonatomic) MQTTCommandType type; 59 | @property (nonatomic) MQTTQosLevel qos; 60 | @property (nonatomic) BOOL retainFlag; 61 | @property (nonatomic) BOOL dupFlag; 62 | @property (nonatomic) UInt16 mid; 63 | @property (strong, nonatomic) NSData * data; 64 | 65 | /** 66 | Enumeration of MQTT Connect return codes 67 | */ 68 | 69 | typedef NS_ENUM(NSUInteger, MQTTConnectReturnCode) { 70 | MQTTConnectAccepted = 0, 71 | MQTTConnectRefusedUnacceptableProtocolVersion, 72 | MQTTConnectRefusedIdentiferRejected, 73 | MQTTConnectRefusedServerUnavailable, 74 | MQTTConnectRefusedBadUserNameOrPassword, 75 | MQTTConnectRefusedNotAuthorized 76 | }; 77 | 78 | // factory methods 79 | + (MQTTMessage *)connectMessageWithClientId:(NSString*)clientId 80 | userName:(NSString*)userName 81 | password:(NSString*)password 82 | keepAlive:(NSInteger)keeplive 83 | cleanSession:(BOOL)cleanSessionFlag 84 | will:(BOOL)will 85 | willTopic:(NSString*)willTopic 86 | willMsg:(NSData*)willData 87 | willQoS:(MQTTQosLevel)willQoS 88 | willRetain:(BOOL)willRetainFlag 89 | protocolLevel:(UInt8)protocolLevel; 90 | 91 | + (MQTTMessage *)pingreqMessage; 92 | + (MQTTMessage *)disconnectMessage; 93 | + (MQTTMessage *)subscribeMessageWithMessageId:(UInt16)msgId 94 | topics:(NSDictionary *)topics; 95 | + (MQTTMessage *)unsubscribeMessageWithMessageId:(UInt16)msgId 96 | topics:(NSArray *)topics; 97 | + (MQTTMessage *)publishMessageWithData:(NSData*)payload 98 | onTopic:(NSString*)topic 99 | qos:(MQTTQosLevel)qosLevel 100 | msgId:(UInt16)msgId 101 | retainFlag:(BOOL)retain 102 | dupFlag:(BOOL)dup; 103 | + (MQTTMessage *)pubackMessageWithMessageId:(UInt16)msgId; 104 | + (MQTTMessage *)pubrecMessageWithMessageId:(UInt16)msgId; 105 | + (MQTTMessage *)pubrelMessageWithMessageId:(UInt16)msgId; 106 | + (MQTTMessage *)pubcompMessageWithMessageId:(UInt16)msgId; 107 | + (MQTTMessage *)messageFromData:(NSData *)data; 108 | 109 | // instance methods 110 | - (instancetype)initWithType:(MQTTCommandType)type; 111 | - (instancetype)initWithType:(MQTTCommandType)type 112 | data:(NSData *)data; 113 | - (instancetype)initWithType:(MQTTCommandType)type 114 | qos:(MQTTQosLevel)qos 115 | data:(NSData *)data; 116 | - (instancetype)initWithType:(MQTTCommandType)type 117 | qos:(MQTTQosLevel)qos 118 | retainFlag:(BOOL)retainFlag 119 | dupFlag:(BOOL)dupFlag 120 | data:(NSData *)data; 121 | 122 | - (NSData *)wireFormat; 123 | 124 | 125 | @end 126 | 127 | @interface NSMutableData (MQTT) 128 | - (void)appendByte:(UInt8)byte; 129 | - (void)appendUInt16BigEndian:(UInt16)val; 130 | - (void)appendMQTTString:(NSString*)s; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTPersistence.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTPersistence.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 22.03.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MQTTMessage.h" 11 | 12 | static BOOL const MQTT_PERSISTENT = NO; 13 | static NSInteger const MQTT_MAX_SIZE = 64 * 1024 * 1024; 14 | static NSInteger const MQTT_MAX_WINDOW_SIZE = 16; 15 | static NSInteger const MQTT_MAX_MESSAGES = 1024; 16 | 17 | /** MQTTFlow is an abstraction of the entity to be stored for persistence */ 18 | 19 | @protocol MQTTFlow 20 | /** The clientID of the flow element */ 21 | @property (strong, nonatomic) NSString *clientId; 22 | 23 | /** The flag indicating incoming or outgoing flow element */ 24 | @property (strong, nonatomic) NSNumber *incomingFlag; 25 | 26 | /** The flag indicating if the flow element is retained*/ 27 | @property (strong, nonatomic) NSNumber *retainedFlag; 28 | 29 | /** The MQTTCommandType of the flow element, might be MQTT_None for offline queueing */ 30 | @property (strong, nonatomic) NSNumber *commandType; 31 | 32 | /** The MQTTQosLevel of the flow element */ 33 | @property (strong, nonatomic) NSNumber *qosLevel; 34 | 35 | /** The messageId of the flow element */ 36 | @property (strong, nonatomic) NSNumber *messageId; 37 | 38 | /** The topic of the flow element */ 39 | @property (strong, nonatomic) NSString *topic; 40 | 41 | /** The data of the flow element */ 42 | @property (strong, nonatomic) NSData *data; 43 | 44 | /** The deadline of the flow elelment before (re)trying transmission */ 45 | @property (strong, nonatomic) NSDate *deadline; 46 | 47 | @end 48 | 49 | /** The MQTTPersistence protocol is an abstraction of persistence classes for MQTTSession */ 50 | 51 | @protocol MQTTPersistence 52 | 53 | /** The maximum Window Size for outgoing inflight messages per clientID. Defaults to 16 */ 54 | @property (nonatomic) NSUInteger maxWindowSize; 55 | 56 | /** The maximum number of messages kept per clientID and direction. Defaults to 1024 */ 57 | @property (nonatomic) NSUInteger maxMessages; 58 | 59 | /** Indicates if the persistence implementation should make the information permannent. Defaults to NO */ 60 | @property (nonatomic) BOOL persistent; 61 | 62 | /** The maximum size of the storage used for persistence in total in bytes. Defaults to 1024*1024 bytes */ 63 | @property (nonatomic) NSUInteger maxSize; 64 | 65 | /** The current Window Size for outgoing inflight messages per clientID. 66 | * @param clientId 67 | * @return the current size of the outgoing inflight window 68 | */ 69 | - (NSUInteger)windowSize:(NSString *)clientId; 70 | 71 | /** Stores one new message 72 | * @param clientId 73 | * @param topic 74 | * @param data 75 | * @param retainFlag 76 | * @param qos 77 | * @param msgId 78 | * @param incomingFlag 79 | * @param commandType 80 | * @param deadline 81 | * @return the created MQTTFlow element or nil if the maxWindowSize has been exceeded 82 | */ 83 | - (id)storeMessageForClientId:(NSString *)clientId 84 | topic:(NSString *)topic 85 | data:(NSData *)data 86 | retainFlag:(BOOL)retainFlag 87 | qos:(MQTTQosLevel)qos 88 | msgId:(UInt16)msgId 89 | incomingFlag:(BOOL)incomingFlag 90 | commandType:(UInt8)commandType 91 | deadline:(NSDate *)deadline; 92 | 93 | /** Deletes an MQTTFlow element 94 | * @param flow 95 | */ 96 | - (void)deleteFlow:(id)flow; 97 | 98 | /** Deletes all MQTTFlow elements of a clientId 99 | * @param clientId 100 | */ 101 | - (void)deleteAllFlowsForClientId:(NSString *)clientId; 102 | 103 | /** Retrieves all MQTTFlow elements of a clientId and direction 104 | * @param clientId 105 | * @param incomingFlag 106 | * @return an NSArray of the retrieved MQTTFlow elements 107 | */ 108 | - (NSArray *)allFlowsforClientId:(NSString *)clientId 109 | incomingFlag:(BOOL)incomingFlag; 110 | 111 | /** Retrieves an MQTTFlow element 112 | * @param clientId 113 | * @param incomingFlag 114 | * @param messageId 115 | * @return the retrieved MQTTFlow element or nil if the elememt was not found 116 | */ 117 | - (id)flowforClientId:(NSString *)clientId 118 | incomingFlag:(BOOL)incomingFlag 119 | messageId:(UInt16)messageId; 120 | 121 | /** sync is called to allow the MQTTPersistence implemetation to save data permanently */ 122 | - (void)sync; 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTSSLSecurityPolicy.h 3 | // MQTTClient.framework 4 | // 5 | // Created by @bobwenx on 15/6/1. 6 | // 7 | // based on 8 | // 9 | // Copyright (c) 2011–2015 AFNetwork (http://alamofire.org/) 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | 29 | #import 30 | #import 31 | 32 | /** 33 | ## SSL Pinning Modes 34 | 35 | The following constants are provided by `MQTTSSLPinningModeNone` as possible SSL pinning modes. 36 | 37 | enum { 38 | MQTTSSLPinningModeNone, 39 | MQTTSSLPinningModePublicKey, 40 | MQTTSSLPinningModeCertificate, 41 | } 42 | 43 | `MQTTSSLPinningModeNone` 44 | Do not used pinned certificates to validate servers. 45 | 46 | `MQTTSSLPinningModePublicKey` 47 | Validate host certificates against public keys of pinned certificates. 48 | 49 | `MQTTSSLPinningModeCertificate` 50 | Validate host certificates against pinned certificates. 51 | */ 52 | typedef NS_ENUM(NSUInteger, MQTTSSLPinningMode) { 53 | // Do not used pinned certificates to validate servers. 54 | MQTTSSLPinningModeNone, 55 | // Validate host certificates against public keys of pinned certificates. 56 | MQTTSSLPinningModePublicKey, 57 | // Validate host certificates against pinned certificates. 58 | MQTTSSLPinningModeCertificate, 59 | }; 60 | 61 | /** 62 | `MQTTSSLSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 63 | 64 | If your app using security model which require pinning SSL certificates to helps prevent man-in-the-middle attacks 65 | and other vulnerabilities. you need to set securityPolicy to properly value(see MQTTSSLSecurityPolicy.h for more detail). 66 | 67 | NOTE: about self-signed server certificates: 68 | if your server using Self-signed certificates to establish SSL/TLS connection, you need to set property: 69 | MQTTSSLSecurityPolicy.allowInvalidCertificates=YES. 70 | 71 | If SSL is enabled, by default it only evaluate server's certificates using CA infrastructure, and for most case, this type of check is enough. 72 | However, if your app using security model which require pinning SSL certificates to helps prevent man-in-the-middle attacks 73 | and other vulnerabilities. you may need to set securityPolicy to properly value(see MQTTSSLSecurityPolicy.h for more detail). 74 | 75 | NOTE: about self-signed server certificates: 76 | In CA infrastructure, you may establish a SSL/TLS connection with server which using self-signed certificates 77 | by install the certificates into OS keychain(either programmatically or manually). however, this method has some disadvantages: 78 | 1. every socket you app created will trust certificates you added. 79 | 2. if user choice to remove certificates from keychain, you app need to handling certificates re-adding. 80 | 81 | If you only want to verify the cert for the socket you are creating and for no other sockets in your app, you need to use 82 | MQTTSSLSecurityPolicy. 83 | And if you use self-signed server certificates, your need to set property: MQTTSSLSecurityPolicy.allowInvalidCertificates=YES 84 | 85 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. 86 | Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication 87 | over an SSL/TLS connection with SSL pinning configured and enabled. 88 | */ 89 | @interface MQTTSSLSecurityPolicy : NSObject 90 | /** 91 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `MQTTSSLPinningMode`. 92 | */ 93 | @property (readonly, nonatomic, assign) MQTTSSLPinningMode SSLPinningMode; 94 | 95 | /** 96 | Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to `YES`. 97 | */ 98 | @property (nonatomic, assign) BOOL validatesCertificateChain; 99 | 100 | /** 101 | The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. 102 | Note: Array item type: NSData - Bytes of X.509 certificate file in der format. 103 | Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. 104 | */ 105 | @property (nonatomic, strong) NSArray *pinnedCertificates; 106 | 107 | /** 108 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 109 | Note: If your server-certificates are self signed, your should set this property to 'YES'. 110 | */ 111 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 112 | 113 | /** 114 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. 115 | */ 116 | @property (nonatomic, assign) BOOL validatesDomainName; 117 | 118 | ///----------------------------------------- 119 | /// @name Getting Specific Security Policies 120 | ///----------------------------------------- 121 | 122 | /** 123 | Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. 124 | 125 | @return The default security policy. 126 | */ 127 | + (instancetype)defaultPolicy; 128 | 129 | ///--------------------- 130 | /// @name Initialization 131 | ///--------------------- 132 | 133 | /** 134 | Creates and returns a security policy with the specified pinning mode. 135 | 136 | @param pinningMode The SSL pinning mode. 137 | 138 | @return A new security policy. 139 | */ 140 | + (instancetype)policyWithPinningMode:(MQTTSSLPinningMode)pinningMode; 141 | 142 | ///------------------------------ 143 | /// @name Evaluating Server Trust 144 | ///------------------------------ 145 | 146 | /** 147 | Whether or not the specified server trust should be accepted, based on the security policy. 148 | 149 | This method should be used when responding to an authentication challenge from a server. 150 | 151 | @param serverTrust The X.509 certificate trust of the server. 152 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 153 | 154 | @return Whether or not to trust the server. 155 | */ 156 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 157 | forDomain:(NSString *)domain; 158 | @end -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTSSLSecurityPolicyDecoder.h 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import 9 | #import "MQTTSSLSecurityPolicy.h" 10 | #import "MQTTCFSocketDecoder.h" 11 | 12 | @interface MQTTSSLSecurityPolicyDecoder : MQTTCFSocketDecoder 13 | @property(strong, nonatomic) MQTTSSLSecurityPolicy *securityPolicy; 14 | @property(strong, nonatomic) NSString *securityDomain; 15 | 16 | @end 17 | 18 | 19 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyDecoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTSSLSecurityPolicyDecoder.m 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import "MQTTSSLSecurityPolicyDecoder.h" 9 | 10 | #import "MQTTLog.h" 11 | 12 | @interface MQTTSSLSecurityPolicyDecoder() 13 | @property (nonatomic) BOOL securityPolicyApplied; 14 | 15 | @end 16 | 17 | @implementation MQTTSSLSecurityPolicyDecoder 18 | 19 | - (instancetype)init { 20 | self = [super init]; 21 | self.securityPolicy = nil; 22 | self.securityDomain = nil; 23 | 24 | return self; 25 | } 26 | 27 | - (BOOL)applySSLSecurityPolicy:(NSStream *)readStream withEvent:(NSStreamEvent)eventCode{ 28 | if(!self.securityPolicy){ 29 | return YES; 30 | } 31 | 32 | if(self.securityPolicyApplied){ 33 | return YES; 34 | } 35 | 36 | SecTrustRef serverTrust = (__bridge SecTrustRef) [readStream propertyForKey: (__bridge NSString *)kCFStreamPropertySSLPeerTrust]; 37 | if(!serverTrust){ 38 | return NO; 39 | } 40 | 41 | self.securityPolicyApplied = [self.securityPolicy evaluateServerTrust:serverTrust forDomain:self.securityDomain]; 42 | return self.securityPolicyApplied; 43 | } 44 | 45 | - (void)stream:(NSStream*)sender handleEvent:(NSStreamEvent)eventCode { 46 | 47 | if (eventCode & NSStreamEventHasBytesAvailable) { 48 | DDLogVerbose(@"[MQTTCFSocketDecoder] NSStreamEventHasBytesAvailable"); 49 | if (![self applySSLSecurityPolicy:sender withEvent:eventCode]){ 50 | self.state = MQTTCFSocketDecoderStateError; 51 | self.error = [NSError errorWithDomain:@"MQTT" 52 | code:errSSLXCertChainInvalid 53 | userInfo:@{NSLocalizedDescriptionKey: @"Unable to apply security policy, the SSL connection is insecure!"}]; 54 | } 55 | } 56 | 57 | [super stream:sender handleEvent:eventCode]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTSSLSecurityPolicyEncoder.h 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import 9 | #import "MQTTSSLSecurityPolicy.h" 10 | #import "MQTTCFSocketEncoder.h" 11 | 12 | @interface MQTTSSLSecurityPolicyEncoder : MQTTCFSocketEncoder 13 | @property(strong, nonatomic) MQTTSSLSecurityPolicy *securityPolicy; 14 | @property(strong, nonatomic) NSString *securityDomain; 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyEncoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTSSLSecurityPolicyEncoder.m 3 | // MQTTClient.framework 4 | // 5 | // Copyright © 2013-2016, Christoph Krey 6 | // 7 | 8 | #import "MQTTSSLSecurityPolicyEncoder.h" 9 | 10 | #import "MQTTLog.h" 11 | 12 | @interface MQTTSSLSecurityPolicyEncoder() 13 | @property (nonatomic) BOOL securityPolicyApplied; 14 | 15 | @end 16 | 17 | @implementation MQTTSSLSecurityPolicyEncoder 18 | 19 | - (instancetype)init { 20 | self = [super init]; 21 | self.securityPolicy = nil; 22 | self.securityDomain = nil; 23 | 24 | return self; 25 | } 26 | 27 | - (BOOL)applySSLSecurityPolicy:(NSStream *)writeStream withEvent:(NSStreamEvent)eventCode; 28 | { 29 | if(!self.securityPolicy){ 30 | return YES; 31 | } 32 | 33 | if(self.securityPolicyApplied){ 34 | return YES; 35 | } 36 | 37 | SecTrustRef serverTrust = (__bridge SecTrustRef) [writeStream propertyForKey: (__bridge NSString *)kCFStreamPropertySSLPeerTrust]; 38 | if(!serverTrust){ 39 | return NO; 40 | } 41 | 42 | self.securityPolicyApplied = [self.securityPolicy evaluateServerTrust:serverTrust forDomain:self.securityDomain]; 43 | return self.securityPolicyApplied; 44 | } 45 | 46 | - (void)stream:(NSStream*)sender handleEvent:(NSStreamEvent)eventCode { 47 | 48 | if (eventCode & NSStreamEventHasSpaceAvailable) { 49 | DDLogVerbose(@"[MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable"); 50 | if(![self applySSLSecurityPolicy:sender withEvent:eventCode]){ 51 | self.state = MQTTCFSocketEncoderStateError; 52 | self.error = [NSError errorWithDomain:@"MQTT" 53 | code:errSSLXCertChainInvalid 54 | userInfo:@{NSLocalizedDescriptionKey: @"Unable to apply security policy, the SSL connection is insecure!"}]; 55 | } 56 | } 57 | [super stream:sender handleEvent:eventCode]; 58 | } 59 | 60 | @end -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyTransport.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTSSLSecurityPolicyTransport.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 06.12.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import "MQTTTransport.h" 10 | #import "MQTTSSLSecurityPolicy.h" 11 | #import "MQTTCFSocketTransport.h" 12 | 13 | /** MQTTSSLSecurityPolicyTransport 14 | * implements an extension of the MQTTCFSocketTransport by replacing the OS's certificate chain evaluation 15 | */ 16 | @interface MQTTSSLSecurityPolicyTransport : MQTTCFSocketTransport 17 | 18 | /** 19 | * The security policy used to evaluate server trust for secure connections. 20 | * 21 | * if your app using security model which require pinning SSL certificates to helps prevent man-in-the-middle attacks 22 | * and other vulnerabilities. you need to set securityPolicy to properly value(see MQTTSSLSecurityPolicy.h for more detail). 23 | * 24 | * NOTE: about self-signed server certificates: 25 | * if your server using Self-signed certificates to establish SSL/TLS connection, you need to set property: 26 | * MQTTSSLSecurityPolicy.allowInvalidCertificates=YES. 27 | */ 28 | @property (strong, nonatomic) MQTTSSLSecurityPolicy *securityPolicy; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTSSLSecurityPolicyTransport.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTSSLSecurityPolicyTransport.m 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 06.12.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import "MQTTSSLSecurityPolicyTransport.h" 10 | #import "MQTTSSLSecurityPolicyEncoder.h" 11 | #import "MQTTSSLSecurityPolicyDecoder.h" 12 | 13 | #import "MQTTLog.h" 14 | 15 | @interface MQTTSSLSecurityPolicyTransport() 16 | @property (strong, nonatomic) MQTTSSLSecurityPolicyEncoder *encoder; 17 | @property (strong, nonatomic) MQTTSSLSecurityPolicyDecoder *decoder; 18 | 19 | @end 20 | 21 | @implementation MQTTSSLSecurityPolicyTransport 22 | @synthesize state; 23 | @synthesize delegate; 24 | 25 | - (instancetype)init { 26 | self = [super init]; 27 | self.securityPolicy = nil; 28 | return self; 29 | } 30 | 31 | - (void)open { 32 | DDLogVerbose(@"[MQTTSSLSecurityPolicyTransport] open"); 33 | self.state = MQTTTransportOpening; 34 | 35 | NSError* connectError; 36 | 37 | CFReadStreamRef readStream; 38 | CFWriteStreamRef writeStream; 39 | 40 | CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)self.host, self.port, &readStream, &writeStream); 41 | 42 | CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); 43 | CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); 44 | 45 | if (self.tls) { 46 | NSMutableDictionary *sslOptions = [[NSMutableDictionary alloc] init]; 47 | 48 | // delegate certificates verify operation to our secure policy. 49 | // by disabling chain validation, it becomes our responsibility to verify that the host at the other end can be trusted. 50 | // the server's certificates will be verified during MQTT encoder/decoder processing. 51 | [sslOptions setObject:(NSString *)kCFStreamSocketSecurityLevelNegotiatedSSL 52 | forKey:(NSString*)kCFStreamSSLLevel]; 53 | [sslOptions setObject:[NSNumber numberWithBool:NO] 54 | forKey:(NSString *)kCFStreamSSLValidatesCertificateChain]; 55 | 56 | if (self.certificates) { 57 | [sslOptions setObject:self.certificates 58 | forKey:(NSString *)kCFStreamSSLCertificates]; 59 | } 60 | 61 | if(!CFReadStreamSetProperty(readStream, kCFStreamPropertySSLSettings, (__bridge CFDictionaryRef)(sslOptions))){ 62 | connectError = [NSError errorWithDomain:@"MQTT" 63 | code:errSSLInternal 64 | userInfo:@{NSLocalizedDescriptionKey : @"Fail to init ssl input stream!"}]; 65 | } 66 | if(!CFWriteStreamSetProperty(writeStream, kCFStreamPropertySSLSettings, (__bridge CFDictionaryRef)(sslOptions))){ 67 | connectError = [NSError errorWithDomain:@"MQTT" 68 | code:errSSLInternal 69 | userInfo:@{NSLocalizedDescriptionKey : @"Fail to init ssl output stream!"}]; 70 | } 71 | } 72 | 73 | if(!connectError){ 74 | self.encoder = [[MQTTSSLSecurityPolicyEncoder alloc] init]; 75 | self.encoder.stream = CFBridgingRelease(writeStream); 76 | self.encoder.securityPolicy = self.tls ? self.securityPolicy : nil; 77 | self.encoder.securityDomain = self.tls ? self.host : nil; 78 | self.encoder.runLoop = self.runLoop; 79 | self.encoder.runLoopMode = self.runLoopMode; 80 | self.encoder.delegate = self; 81 | [self.encoder open]; 82 | 83 | self.decoder = [[MQTTSSLSecurityPolicyDecoder alloc] init]; 84 | self.decoder.stream = CFBridgingRelease(readStream); 85 | self.decoder.securityPolicy = self.tls ? self.securityPolicy : nil; 86 | self.decoder.securityDomain = self.tls ? self.host : nil; 87 | self.decoder.runLoop = self.runLoop; 88 | self.decoder.runLoopMode = self.runLoopMode; 89 | self.decoder.delegate = self; 90 | [self.decoder open]; 91 | 92 | } else { 93 | [self close]; 94 | } 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTTransport.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTTransport.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 06.12.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol MQTTTransportDelegate; 12 | 13 | /** MQTTTransport is a protocol abstracting the underlying transport level for MQTTClient 14 | * 15 | */ 16 | @protocol MQTTTransport 17 | 18 | /** MQTTTransport state defines the possible state of an abstract transport 19 | * 20 | */ 21 | typedef NS_ENUM(NSInteger, MQTTTransportState) { 22 | 23 | /** MQTTTransportCreated indicates an initialized transport */ 24 | MQTTTransportCreated = 0, 25 | 26 | /** MQTTTransportOpening indicates a transport in the process of opening a connection */ 27 | MQTTTransportOpening, 28 | 29 | /** MQTTTransportCreated indicates a transport opened ready for communication */ 30 | MQTTTransportOpen, 31 | 32 | /** MQTTTransportCreated indicates a transport in the process of closing */ 33 | MQTTTransportClosing, 34 | 35 | /** MQTTTransportCreated indicates a closed transport */ 36 | MQTTTransportClosed 37 | }; 38 | 39 | /** runLoop The runLoop where the streams are scheduled. If nil, defaults to [NSRunLoop currentRunLoop]. */ 40 | @property (strong, nonatomic) NSRunLoop * _Nonnull runLoop; 41 | 42 | /** runLoopMode The runLoopMode where the streams are scheduled. If nil, defaults to NSRunLoopCommonModes. */ 43 | @property (strong, nonatomic) NSString * _Nonnull runLoopMode; 44 | 45 | /** MQTTTransportDelegate needs to be set to a class implementing th MQTTTransportDelegate protocol 46 | * to receive delegate messages. 47 | */ 48 | @property (strong, nonatomic) _Nullable id delegate; 49 | 50 | /** state contains the current MQTTTransportState of the transport */ 51 | @property (nonatomic) MQTTTransportState state; 52 | 53 | /** open opens the transport and prepares it for communication 54 | * actual transports may require additional parameters to be set before opening 55 | */ 56 | - (void)open; 57 | 58 | /** send transmits a data message 59 | * @param data data to be send, might be zero length 60 | * @result a boolean indicating if the data could be send or not 61 | */ 62 | - (BOOL)send:(nonnull NSData *)data; 63 | 64 | /** close closes the transport */ 65 | - (void)close; 66 | 67 | @end 68 | 69 | /** MQTTTransportDelegate protocol 70 | * Note: the implementation of the didReceiveMessage method is mandatory, the others are optional 71 | */ 72 | @protocol MQTTTransportDelegate 73 | 74 | /** didReceiveMessage gets called when a message was received 75 | * @param mqttTransport the transport on which the message was received 76 | * @param message the data received which may be zero length 77 | */ 78 | - (void)mqttTransport:(nonnull id)mqttTransport didReceiveMessage:(nonnull NSData *)message; 79 | 80 | @optional 81 | 82 | /** mqttTransportDidOpen gets called when a transport is successfully opened 83 | * @param mqttTransport the transport which was successfully opened 84 | */ 85 | - (void)mqttTransportDidOpen:(_Nonnull id)mqttTransport; 86 | 87 | /** didFailWithError gets called when an error was detected on the transport 88 | * @param mqttTransport the transport which detected the error 89 | * @param error available error information, might be nil 90 | */ 91 | - (void)mqttTransport:(_Nonnull id)mqttTransport didFailWithError:(nullable NSError *)error; 92 | 93 | /** mqttTransportDidClose gets called when the transport closed 94 | * @param mqttTransport the transport which was closed 95 | */ 96 | - (void)mqttTransportDidClose:(_Nonnull id)mqttTransport; 97 | 98 | @end 99 | 100 | @interface MQTTTransport : NSObject 101 | @end 102 | 103 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTTransport.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTTransport.m 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 05.01.16. 6 | // Copyright © 2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import "MQTTTransport.h" 10 | 11 | #import "MQTTLog.h" 12 | 13 | @implementation MQTTTransport 14 | @synthesize state; 15 | @synthesize runLoop; 16 | @synthesize runLoopMode; 17 | @synthesize delegate; 18 | 19 | - (instancetype)init { 20 | self = [super init]; 21 | self.state = MQTTTransportCreated; 22 | self.runLoop = [NSRunLoop currentRunLoop]; 23 | self.runLoopMode = NSRunLoopCommonModes; 24 | return self; 25 | } 26 | 27 | - (void)open { 28 | DDLogError(@"MQTTTransport is abstract class"); 29 | } 30 | 31 | - (void)close { 32 | DDLogError(@"MQTTTransport is abstract class"); 33 | } 34 | 35 | - (BOOL)send:(NSData *)data { 36 | DDLogError(@"MQTTTransport is abstract class"); 37 | return FALSE; 38 | } 39 | 40 | @end -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTWebsocketTransport/MQTTWebsocketTransport.h: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTWebsocketTransport.h 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 06.12.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MQTTTransport.h" 11 | #import 12 | 13 | /** MQTTCFSocketTransport 14 | * implements an MQTTTransport on top of Websockets (SocketRocket) 15 | */ 16 | @interface MQTTWebsocketTransport : MQTTTransport 17 | 18 | /** host an NSString containing the hostName or IP address of the host to connect to 19 | * defaults to @"localhost" 20 | */ 21 | @property (strong, nonatomic) NSString *host; 22 | 23 | /** port an unsigned 16 bit integer containing the IP port number to connect to 24 | * defaults to 80 25 | */ 26 | @property (nonatomic) UInt16 port; 27 | 28 | /** tls a boolean indicating whether the transport should be using security 29 | * defaults to NO 30 | */ 31 | @property (nonatomic) BOOL tls; 32 | 33 | /** path an NSString indicating the path component of the websocket URL request 34 | * defaults to @"/html" 35 | */ 36 | @property (strong, nonatomic) NSString *path; 37 | 38 | /** allowUntrustedCertificates a boolean indicating whether self signed or expired certificates should be accepted 39 | * defaults to NO 40 | */ 41 | @property (nonatomic) BOOL allowUntrustedCertificates; 42 | 43 | /** pinnedCertificates an NSArray containing certificates to validate server certificates against 44 | * defaults to nil 45 | */ 46 | @property (strong, nonatomic) NSArray *pinnedCertificates; 47 | 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/MQTTClient/MQTTClient/MQTTWebsocketTransport/MQTTWebsocketTransport.m: -------------------------------------------------------------------------------- 1 | // 2 | // MQTTWebsocketTransport.m 3 | // MQTTClient 4 | // 5 | // Created by Christoph Krey on 06.12.15. 6 | // Copyright © 2015-2016 Christoph Krey. All rights reserved. 7 | // 8 | 9 | #import "MQTTWebsocketTransport.h" 10 | 11 | #import "../MQTTLog.h" 12 | 13 | @interface MQTTWebsocketTransport() 14 | @property (strong, nonatomic) SRWebSocket *websocket; 15 | @end 16 | 17 | @implementation MQTTWebsocketTransport 18 | @synthesize state; 19 | @synthesize delegate; 20 | @synthesize runLoop; 21 | @synthesize runLoopMode; 22 | 23 | - (instancetype)init { 24 | self = [super init]; 25 | self.host = @"localhost"; 26 | self.port = 80; 27 | self.path = @"/mqtt"; 28 | self.tls = false; 29 | self.allowUntrustedCertificates = false; 30 | self.pinnedCertificates = nil; 31 | return self; 32 | } 33 | 34 | - (void)open { 35 | DDLogVerbose(@"[MQTTWebsocketTransport] open"); 36 | self.state = MQTTTransportOpening; 37 | 38 | NSString *protocol = (self.tls) ? @"wss" : @"ws"; 39 | NSString *portString = (self.port == 0) ? @"" : [NSString stringWithFormat:@":%d",(unsigned int)self.port]; 40 | NSString *path = self.path; 41 | NSArray *protocols = @[@"mqtt"]; 42 | NSString *urlString = [NSString stringWithFormat:@"%@://%@%@%@", 43 | protocol, 44 | self.host, 45 | portString, 46 | path]; 47 | NSURL *url = [NSURL URLWithString:urlString]; 48 | NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; 49 | urlRequest.SR_SSLPinnedCertificates = self.pinnedCertificates; 50 | 51 | self.websocket = [[SRWebSocket alloc] initWithURLRequest:urlRequest 52 | protocols:protocols 53 | allowsUntrustedSSLCertificates:self.allowUntrustedCertificates]; 54 | 55 | self.websocket.delegate = self; 56 | [self.websocket open]; 57 | } 58 | 59 | - (BOOL)send:(nonnull NSData *)data { 60 | DDLogVerbose(@"[MQTTWebsocketTransport] send(%ld):%@", (unsigned long)data.length, 61 | [data subdataWithRange:NSMakeRange(0, MIN(256, data.length))]); 62 | if (self.websocket.readyState == SR_OPEN) { 63 | [self.websocket send:data]; 64 | return true; 65 | } else { 66 | return false; 67 | } 68 | } 69 | 70 | - (void)close { 71 | DDLogVerbose(@"[MQTTWebsocketTransport] close"); 72 | self.state = MQTTTransportClosing; 73 | [self.websocket close]; 74 | } 75 | 76 | - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message { 77 | NSData *data; 78 | if ([message isKindOfClass:[NSData class]]) { 79 | data = (NSData *)message; 80 | } 81 | DDLogVerbose(@"[MQTTWebsocketTransport] didReceiveMessage(%ld)", (unsigned long)(data ? data.length : -1)); 82 | 83 | if (self.delegate) { 84 | if ([self.delegate respondsToSelector:@selector(mqttTransport:didReceiveMessage:)]) { 85 | [self.delegate mqttTransport:self didReceiveMessage:message]; 86 | } 87 | } 88 | } 89 | 90 | - (void)webSocketDidOpen:(SRWebSocket *)webSocket{ 91 | DDLogVerbose(@"[MQTTWebsocketTransport] connected to websocket"); 92 | self.state = MQTTTransportOpen; 93 | if (self.delegate) { 94 | if ([self.delegate respondsToSelector:@selector(mqttTransportDidOpen:)]) { 95 | [self.delegate mqttTransportDidOpen:self]; 96 | } 97 | } 98 | } 99 | 100 | - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error{ 101 | DDLogInfo(@"[MQTTWebsocketTransport] Failed to connect : %@",[error debugDescription]); 102 | self.state = MQTTTransportClosed; 103 | self.websocket.delegate = nil; 104 | [self.websocket close]; 105 | if (self.delegate) { 106 | if ([self.delegate respondsToSelector:@selector(mqttTransport:didFailWithError:)]) { 107 | [self.delegate mqttTransport:self didFailWithError:error]; 108 | } 109 | } 110 | } 111 | 112 | - (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean{ 113 | DDLogVerbose(@"[MQTTWebsocketTransport] ConnectionClosed : %@",reason); 114 | self.state = MQTTTransportClosed; 115 | self.websocket.delegate = nil; 116 | if (self.delegate) { 117 | if ([self.delegate respondsToSelector:@selector(mqttTransportDidClose:)]) { 118 | [self.delegate mqttTransportDidClose:self]; 119 | } 120 | } 121 | } 122 | 123 | - (void)webSocket:(SRWebSocket *)webSocket didReceivePong:(NSData *)pongPayload{ 124 | DDLogVerbose(@"[MQTTWebsocketTransport] webSocket didReceivePong:%@", pongPayload); 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/MQTTClient/README.md: -------------------------------------------------------------------------------- 1 | MQTT-Client-Framework 2 | ===================== 3 | 4 | an Objective-C native MQTT Framework http://mqtt.org 5 | 6 | ### Tested with 7 | 8 | * mosquitto 9 | * paho 10 | * rabbitmq 11 | * hivemq 12 | * rsmb 13 | * mosca 14 | * vernemq 15 | * emqtt 16 | * moquette 17 | * ActiveMQ 18 | * Apollo 19 | * CloudMQTT 20 | * aws 21 | 22 | ### Howto 23 | 24 | Use the CocoaPod MQTTClient! 25 | 26 | Add this to your Podfile: 27 | ``` 28 | pod 'MQTTClient' 29 | ``` 30 | 31 | Additionally add this subspec if you want to use MQTT over Websockets: 32 | ``` 33 | pod 'MQTTClient/Websocket' 34 | ``` 35 | 36 | Or use the dynamic library created in the MQTTFramework target. 37 | 38 | Or include the source from here. 39 | 40 | [Documentation](MQTTClient/dist/documentation/html/index.html) 41 | 42 | ### Usage 43 | 44 | Create a new client and connect to a broker: 45 | 46 | ```objective-c 47 | 48 | \@interface MyDelegate : ... MQTTSessionDelegate> 49 | ... 50 | 51 | MQTTCFSocketTransport *transport = [[MQTTCFSocketTransport alloc] init]; 52 | transport.host = @"localhost"; 53 | transport.port = 1883; 54 | 55 | session = [[MQTTSession alloc] init]; 56 | session.transport = transport; 57 | 58 | session.delegate=self; 59 | 60 | [session connectAndWaitTimeout:30]; //this is part of the synchronous API 61 | 62 | ``` 63 | 64 | Subscribe to a topic: 65 | 66 | ```objective-c 67 | [session subscribeToTopic:@"example/#" atLevel:2 subscribeHandler:^(NSError *error, NSArray *gQoss){ 68 | if (error) { 69 | NSLog(@"Subscription failed %@", error.localizedDescription); 70 | } else { 71 | NSLog(@"Subscription sucessfull! Granted Qos: %@", gQoss); 72 | } 73 | }]; // this is part of the block API 74 | 75 | ``` 76 | 77 | Add the following to receive messages for the subscribed topics 78 | ```objective-c 79 | - (void)newMessage:(MQTTSession *)session 80 | data:(NSData *)data 81 | onTopic:(NSString *)topic 82 | qos:(MQTTQosLevel)qos 83 | retained:(BOOL)retained 84 | mid:(unsigned int)mid { 85 | // this is one of the delegate callbacks 86 | } 87 | ``` 88 | 89 | Publish a message to a topic: 90 | 91 | ```objective-c 92 | [session publishAndWaitData:data 93 | onTopic:@"topic" 94 | retain:NO 95 | qos:MQTTQosLevelAtLeastOnce]; // this is part of the asynchronous API 96 | ``` 97 | 98 | #### docs 99 | 100 | Documentation generated with doxygen http://doxygen.org 101 | 102 | #### Comparison MQTT Clients for iOS (incomplete) 103 | 104 | |Wrapper|---|----|MQTTKit |Marquette|Moscapsule|Musqueteer|MQTT-Client|MqttSDK|CocoaMQTT| 105 | |-------|---|----|---------|---------|----------|----------|-----------|-------|---------| 106 | | | | |Obj-C |Obj-C |Swift |Obj-C |Obj-C |Obj-C |Swift | 107 | |Library|IBM|Paho|Mosquitto|Mosquitto|Mosquitto |Mosquitto |native |native |native | 108 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaLumberjack (2.2.0): 3 | - CocoaLumberjack/Default (= 2.2.0) 4 | - CocoaLumberjack/Extensions (= 2.2.0) 5 | - CocoaLumberjack/Core (2.2.0) 6 | - CocoaLumberjack/Default (2.2.0): 7 | - CocoaLumberjack/Core 8 | - CocoaLumberjack/Extensions (2.2.0): 9 | - CocoaLumberjack/Default 10 | - MQTTClient (0.6.9): 11 | - MQTTClient/Core (= 0.6.9) 12 | - MQTTClient/Core (0.6.9): 13 | - CocoaLumberjack 14 | - MQTTClient/Websocket (0.6.9): 15 | - MQTTClient/Core 16 | - SocketRocket 17 | - SocketRocket (0.4.2) 18 | 19 | DEPENDENCIES: 20 | - MQTTClient 21 | - MQTTClient/Websocket 22 | 23 | SPEC CHECKSUMS: 24 | CocoaLumberjack: 17fe8581f84914d5d7e6360f7c70022b173c3ae0 25 | MQTTClient: db15b4359780774a3ad876672624d7bd6f8a04d0 26 | SocketRocket: ffe08119b00ef982f6c37052a4705a057c8494ad 27 | 28 | COCOAPODS: 0.39.0 29 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/SocketRocket/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright 2012 Square Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/SocketRocket/SocketRocket/SRWebSocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2012 Square Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | #import 19 | 20 | typedef NS_ENUM(NSInteger, SRReadyState) { 21 | SR_CONNECTING = 0, 22 | SR_OPEN = 1, 23 | SR_CLOSING = 2, 24 | SR_CLOSED = 3, 25 | }; 26 | 27 | typedef enum SRStatusCode : NSInteger { 28 | SRStatusCodeNormal = 1000, 29 | SRStatusCodeGoingAway = 1001, 30 | SRStatusCodeProtocolError = 1002, 31 | SRStatusCodeUnhandledType = 1003, 32 | // 1004 reserved. 33 | SRStatusNoStatusReceived = 1005, 34 | // 1004-1006 reserved. 35 | SRStatusCodeInvalidUTF8 = 1007, 36 | SRStatusCodePolicyViolated = 1008, 37 | SRStatusCodeMessageTooBig = 1009, 38 | } SRStatusCode; 39 | 40 | @class SRWebSocket; 41 | 42 | extern NSString *const SRWebSocketErrorDomain; 43 | extern NSString *const SRHTTPResponseErrorKey; 44 | 45 | #pragma mark - SRWebSocketDelegate 46 | 47 | @protocol SRWebSocketDelegate; 48 | 49 | #pragma mark - SRWebSocket 50 | 51 | @interface SRWebSocket : NSObject 52 | 53 | @property (nonatomic, weak) id delegate; 54 | 55 | @property (nonatomic, readonly) SRReadyState readyState; 56 | @property (nonatomic, readonly, retain) NSURL *url; 57 | 58 | 59 | @property (nonatomic, readonly) CFHTTPMessageRef receivedHTTPHeaders; 60 | 61 | // Optional array of cookies (NSHTTPCookie objects) to apply to the connections 62 | @property (nonatomic, readwrite) NSArray * requestCookies; 63 | 64 | // This returns the negotiated protocol. 65 | // It will be nil until after the handshake completes. 66 | @property (nonatomic, readonly, copy) NSString *protocol; 67 | 68 | // Protocols should be an array of strings that turn into Sec-WebSocket-Protocol. 69 | - (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols allowsUntrustedSSLCertificates:(BOOL)allowsUntrustedSSLCertificates; 70 | - (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols; 71 | - (id)initWithURLRequest:(NSURLRequest *)request; 72 | 73 | // Some helper constructors. 74 | - (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols allowsUntrustedSSLCertificates:(BOOL)allowsUntrustedSSLCertificates; 75 | - (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols; 76 | - (id)initWithURL:(NSURL *)url; 77 | 78 | // Delegate queue will be dispatch_main_queue by default. 79 | // You cannot set both OperationQueue and dispatch_queue. 80 | - (void)setDelegateOperationQueue:(NSOperationQueue*) queue; 81 | - (void)setDelegateDispatchQueue:(dispatch_queue_t) queue; 82 | 83 | // By default, it will schedule itself on +[NSRunLoop SR_networkRunLoop] using defaultModes. 84 | - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; 85 | - (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; 86 | 87 | // SRWebSockets are intended for one-time-use only. Open should be called once and only once. 88 | - (void)open; 89 | 90 | - (void)close; 91 | - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; 92 | 93 | // Send a UTF8 String or Data. 94 | - (void)send:(id)data; 95 | 96 | // Send Data (can be nil) in a ping message. 97 | - (void)sendPing:(NSData *)data; 98 | 99 | @end 100 | 101 | #pragma mark - SRWebSocketDelegate 102 | 103 | @protocol SRWebSocketDelegate 104 | 105 | // message will either be an NSString if the server is using text 106 | // or NSData if the server is using binary. 107 | - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message; 108 | 109 | @optional 110 | 111 | - (void)webSocketDidOpen:(SRWebSocket *)webSocket; 112 | - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error; 113 | - (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean; 114 | - (void)webSocket:(SRWebSocket *)webSocket didReceivePong:(NSData *)pongPayload; 115 | 116 | @end 117 | 118 | #pragma mark - NSURLRequest (CertificateAdditions) 119 | 120 | @interface NSURLRequest (CertificateAdditions) 121 | 122 | @property (nonatomic, retain, readonly) NSArray *SR_SSLPinnedCertificates; 123 | 124 | @end 125 | 126 | #pragma mark - NSMutableURLRequest (CertificateAdditions) 127 | 128 | @interface NSMutableURLRequest (CertificateAdditions) 129 | 130 | @property (nonatomic, retain) NSArray *SR_SSLPinnedCertificates; 131 | 132 | @end 133 | 134 | #pragma mark - NSRunLoop (SRWebSocket) 135 | 136 | @interface NSRunLoop (SRWebSocket) 137 | 138 | + (NSRunLoop *)SR_networkRunLoop; 139 | 140 | @end 141 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/CocoaLumberjack/CocoaLumberjack-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_CocoaLumberjack : NSObject 3 | @end 4 | @implementation PodsDummy_CocoaLumberjack 5 | @end 6 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/CocoaLumberjack/CocoaLumberjack-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/CocoaLumberjack/CocoaLumberjack.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/CocoaLumberjack" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaLumberjack" "${PODS_ROOT}/Headers/Public/MQTTClient" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | PODS_ROOT = ${SRCROOT} 4 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/MQTTClient/MQTTClient-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MQTTClient : NSObject 3 | @end 4 | @implementation PodsDummy_MQTTClient 5 | @end 6 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/MQTTClient/MQTTClient-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/MQTTClient/MQTTClient.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MQTTClient" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaLumberjack" "${PODS_ROOT}/Headers/Public/MQTTClient" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | OTHER_LDFLAGS = -l"icucore" 4 | PODS_ROOT = ${SRCROOT} 5 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods-RCTMqtt/Pods-RCTMqtt-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RCTMqtt : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RCTMqtt 5 | @end 6 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods-RCTMqtt/Pods-RCTMqtt-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods-RCTMqtt/Pods-RCTMqtt-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | realpath() { 12 | DIRECTORY="$(cd "${1%/*}" && pwd)" 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | 61 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 62 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 63 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 64 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 65 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 66 | fi 67 | rm -f "$RESOURCES_TO_COPY" 68 | 69 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 70 | then 71 | case "${TARGETED_DEVICE_FAMILY}" in 72 | 1,2) 73 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 74 | ;; 75 | 1) 76 | TARGET_DEVICE_ARGS="--target-device iphone" 77 | ;; 78 | 2) 79 | TARGET_DEVICE_ARGS="--target-device ipad" 80 | ;; 81 | *) 82 | TARGET_DEVICE_ARGS="--target-device mac" 83 | ;; 84 | esac 85 | 86 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 87 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 88 | while read line; do 89 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 90 | XCASSET_FILES+=("$line") 91 | fi 92 | done <<<"$OTHER_XCASSETS" 93 | 94 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 95 | fi 96 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods-RCTMqtt/Pods-RCTMqtt.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaLumberjack" "${PODS_ROOT}/Headers/Public/MQTTClient" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaLumberjack" -isystem "${PODS_ROOT}/Headers/Public/MQTTClient" -isystem "${PODS_ROOT}/Headers/Public/SocketRocket" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaLumberjack" -l"MQTTClient" -l"SocketRocket" -l"icucore" -framework "CFNetwork" -framework "Security" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods-RCTMqtt/Pods-RCTMqtt.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaLumberjack" "${PODS_ROOT}/Headers/Public/MQTTClient" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaLumberjack" -isystem "${PODS_ROOT}/Headers/Public/MQTTClient" -isystem "${PODS_ROOT}/Headers/Public/SocketRocket" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaLumberjack" -l"MQTTClient" -l"SocketRocket" -l"icucore" -framework "CFNetwork" -framework "Security" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods/Pods-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods : NSObject 3 | @end 4 | @implementation PodsDummy_Pods 5 | @end 6 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods/Pods-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods/Pods-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | realpath() { 12 | DIRECTORY="$(cd "${1%/*}" && pwd)" 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | 61 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 62 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 63 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 64 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 65 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 66 | fi 67 | rm -f "$RESOURCES_TO_COPY" 68 | 69 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 70 | then 71 | case "${TARGETED_DEVICE_FAMILY}" in 72 | 1,2) 73 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 74 | ;; 75 | 1) 76 | TARGET_DEVICE_ARGS="--target-device iphone" 77 | ;; 78 | 2) 79 | TARGET_DEVICE_ARGS="--target-device ipad" 80 | ;; 81 | *) 82 | TARGET_DEVICE_ARGS="--target-device mac" 83 | ;; 84 | esac 85 | 86 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 87 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 88 | while read line; do 89 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 90 | XCASSET_FILES+=("$line") 91 | fi 92 | done <<<"$OTHER_XCASSETS" 93 | 94 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 95 | fi 96 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods/Pods.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaLumberjack" "${PODS_ROOT}/Headers/Public/MQTTClient" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaLumberjack" -isystem "${PODS_ROOT}/Headers/Public/MQTTClient" -isystem "${PODS_ROOT}/Headers/Public/SocketRocket" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaLumberjack" -l"MQTTClient" -l"SocketRocket" -l"icucore" -framework "CFNetwork" -framework "Security" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/Pods/Pods.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaLumberjack" "${PODS_ROOT}/Headers/Public/MQTTClient" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaLumberjack" -isystem "${PODS_ROOT}/Headers/Public/MQTTClient" -isystem "${PODS_ROOT}/Headers/Public/SocketRocket" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaLumberjack" -l"MQTTClient" -l"SocketRocket" -l"icucore" -framework "CFNetwork" -framework "Security" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/SocketRocket/SocketRocket-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SocketRocket : NSObject 3 | @end 4 | @implementation PodsDummy_SocketRocket 5 | @end 6 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/SocketRocket/SocketRocket-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /ios/RCTMqtt/Pods/Target Support Files/SocketRocket/SocketRocket.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SocketRocket" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaLumberjack" "${PODS_ROOT}/Headers/Public/MQTTClient" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | OTHER_LDFLAGS = -l"icucore" -framework "CFNetwork" -framework "Security" 4 | PODS_ROOT = ${SRCROOT} 5 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /ios/RCTMqtt/RCTMqtt.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTMqtt.h 3 | // RCTMqtt 4 | // 5 | // Created by Tuan PM on 2/2/16. 6 | // Copyright © 2016 Tuan PM. All rights reserved. 7 | // 8 | #import 9 | -------------------------------------------------------------------------------- /ios/RCTMqtt/RCTMqtt.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTMqtt.m 3 | // RCTMqtt 4 | // 5 | // Created by Tuan PM on 2/2/16. 6 | // Copyright © 2016 Tuan PM. All rights reserved. 7 | // 8 | 9 | #import "RCTMqtt.h" 10 | #import "RCTBridgeModule.h" 11 | #import "RCTLog.h" 12 | #import "RCTUtils.h" 13 | #import "RCTEventDispatcher.h" 14 | 15 | #import 16 | #import 17 | #import 18 | #import "Mqtt.h" 19 | 20 | @interface RCTMqtt : NSObject 21 | 22 | @end 23 | 24 | @interface RCTMqtt () 25 | @property NSMutableDictionary *clients; 26 | @end 27 | 28 | 29 | @implementation RCTMqtt 30 | 31 | @synthesize bridge = _bridge; 32 | 33 | 34 | -(int)getRandomNumberBetween:(int)from to:(int)to { 35 | 36 | return (int)from + arc4random() % (to-from+1); 37 | } 38 | 39 | RCT_EXPORT_MODULE(); 40 | 41 | 42 | - (instancetype)init 43 | { 44 | if ((self = [super init])) { 45 | [DDLog addLogger:[DDASLLogger sharedInstance]]; 46 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 47 | 48 | NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter]; 49 | 50 | _clients = [[NSMutableDictionary alloc] init]; 51 | 52 | [defaultCenter addObserver:self 53 | selector:@selector(appDidBecomeActive) 54 | name:UIApplicationDidBecomeActiveNotification 55 | object:nil]; 56 | 57 | 58 | 59 | } 60 | return self; 61 | 62 | } 63 | 64 | - (void)appDidBecomeActive { 65 | // if(self.isConnect) { 66 | // [self.manager addObserver:self 67 | // forKeyPath:@"state" 68 | // options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew 69 | // context:nil]; 70 | // } 71 | 72 | } 73 | 74 | RCT_EXPORT_METHOD(createClient:(NSDictionary *) options 75 | resolver:(RCTPromiseResolveBlock)resolve 76 | rejecter:(RCTPromiseRejectBlock)reject) { 77 | 78 | int clientRef = [self getRandomNumberBetween:1000 to:9999]; 79 | 80 | Mqtt *client = [[Mqtt alloc] initWithBrigde:[self bridge] 81 | options:options 82 | clientRef:clientRef]; 83 | 84 | [[self clients] setObject:client forKey:[NSNumber numberWithInt:clientRef]]; 85 | resolve([NSNumber numberWithInt:clientRef]); 86 | 87 | } 88 | 89 | RCT_EXPORT_METHOD(removeClient:(int) clientRef 90 | resolver:(RCTPromiseResolveBlock)resolve 91 | rejecter:(RCTPromiseRejectBlock)reject) { 92 | 93 | [[self clients] removeObjectForKey:[NSNumber numberWithInt:clientRef]]; 94 | resolve([NSNumber numberWithInt:clientRef]); 95 | 96 | } 97 | 98 | RCT_EXPORT_METHOD(connect:(nonnull NSNumber *) clientRef) { 99 | 100 | [[[self clients] objectForKey:clientRef] connect]; 101 | 102 | } 103 | 104 | 105 | RCT_EXPORT_METHOD(disconnect:(nonnull NSNumber *) clientRef) { 106 | [[[self clients] objectForKey:clientRef] disconnect]; 107 | } 108 | 109 | RCT_EXPORT_METHOD(subscribe:(nonnull NSNumber *) clientRef topic:(NSString *)topic qos:(nonnull NSNumber *)qos) { 110 | [[[self clients] objectForKey:clientRef] subscribe:topic qos:qos]]; 111 | 112 | } 113 | 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]; 119 | 120 | } 121 | 122 | - (void)dealloc 123 | { 124 | 125 | 126 | } 127 | 128 | @end 129 | 130 | 131 | -------------------------------------------------------------------------------- /ios/RCTMqtt/RCTMqtt.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-mqtt", 3 | "version": "0.1.0-beta4", 4 | "description": "MQTT client for react-native", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/tuanpmt/react-native-mqtt.git" 12 | }, 13 | "keywords": [ 14 | "mqtt", 15 | "reactnative", 16 | "iot" 17 | ], 18 | "author": "Tuan PM (http://tuanpm.net)", 19 | "license": "MIT", 20 | "bugs": { 21 | "url": "https://github.com/tuanpmt/react-native-mqtt/issues" 22 | }, 23 | "homepage": "https://github.com/tuanpmt/react-native-mqtt#readme" 24 | } 25 | --------------------------------------------------------------------------------