Skip to content

Commit

Permalink
fix MqttAuthProperties lose import Foundation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
leeway1208 committed Nov 13, 2021
1 parent 57e8770 commit e7e8992
Show file tree
Hide file tree
Showing 25 changed files with 26 additions and 59 deletions.
4 changes: 2 additions & 2 deletions CocoaMQTT.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CocoaMQTT"
s.version = "2.0.0"
s.version = "2.0.1"
s.summary = "MQTT v3.1.1 client library for iOS and OS X written with Swift 5"
s.homepage = "https://github.com/emqx/CocoaMQTT"
s.license = { :type => "MIT" }
Expand All @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "10.0"
s.tvos.deployment_target = "10.0"
# s.watchos.deployment_target = "2.0"
s.source = { :git => "https://github.com/emqx/CocoaMQTT.git", :tag => "2.0.0"}
s.source = { :git => "https://github.com/emqx/CocoaMQTT.git", :tag => "2.0.1"}
s.default_subspec = 'Core'

s.subspec 'Core' do |ss|
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TVOS Target: 10.0 or above
Install using [CocoaPods](http://cocoapods.org) by adding this line to your Podfile:

```ruby
pod 'CocoaMQTT, '~> 2.0.0''
pod 'CocoaMQTT, '~> 2.0.1''
```

Then, run the following command:
Expand Down
28 changes: 13 additions & 15 deletions Source/CocoaMQTT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import Foundation
import CocoaAsyncSocket



/**
* Conn Ack
*/
Expand All @@ -25,13 +23,13 @@ import CocoaAsyncSocket

public var description: String {
switch self {
case .accept: return "accept"
case .unacceptableProtocolVersion: return "unacceptableProtocolVersion"
case .identifierRejected: return "identifierRejected"
case .serverUnavailable: return "serverUnavailable"
case .badUsernameOrPassword: return "badUsernameOrPassword"
case .notAuthorized: return "notAuthorized"
case .reserved: return "reserved"
case .accept: return "accept"
case .unacceptableProtocolVersion: return "unacceptableProtocolVersion"
case .identifierRejected: return "identifierRejected"
case .serverUnavailable: return "serverUnavailable"
case .badUsernameOrPassword: return "badUsernameOrPassword"
case .notAuthorized: return "notAuthorized"
case .reserved: return "reserved"
}
}
}
Expand Down Expand Up @@ -516,7 +514,7 @@ extension CocoaMQTT: CocoaMQTTDeliverProtocol {

self.delegate?.mqtt(self, didPublishMessage: message, id: msgid)
self.didPublishMessage(self, message, msgid)

} else if let pubrel = frame as? FramePubRel {
// -- Send PUBREL
send(pubrel, tag: Int(pubrel.msgid))
Expand All @@ -542,8 +540,8 @@ extension CocoaMQTT: CocoaMQTTSocketDelegate {
}

public func socket(_ socket: CocoaMQTTSocketProtocol,
didReceive trust: SecTrust,
completionHandler: @escaping (Bool) -> Swift.Void) {
didReceive trust: SecTrust,
completionHandler: @escaping (Bool) -> Swift.Void) {

printDebug("Call the SSL/TLS manually validating function")

Expand Down Expand Up @@ -589,7 +587,7 @@ extension CocoaMQTT: CocoaMQTTSocketDelegate {
}
}

guard autoReconnect else {
guard autoReconnect else {
return
}

Expand All @@ -615,7 +613,7 @@ extension CocoaMQTT: CocoaMQTTSocketDelegate {
extension CocoaMQTT: CocoaMQTTReaderDelegate {

func didReceive(_ reader: CocoaMQTTReader, disconnect: FrameDisconnect) {

}

func didReceive(_ reader: CocoaMQTTReader, auth: FrameAuth) {
Expand Down Expand Up @@ -746,7 +744,7 @@ extension CocoaMQTT: CocoaMQTTReaderDelegate {
delegate?.mqtt(self, didSubscribeTopics: success, failed: failed)
didSubscribeTopics(self, success, failed)
}

func didReceive(_ reader: CocoaMQTTReader, unsuback: FrameUnsubAck) {
printDebug("RECV: \(unsuback)")

Expand Down
16 changes: 8 additions & 8 deletions Source/CocoaMQTT5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import CocoaAsyncSocket

public var description: String {
switch self {
case .connecting: return "connecting"
case .connected: return "connected"
case .disconnected: return "disconnected"
case .connecting: return "connecting"
case .connected: return "connected"
case .disconnected: return "disconnected"
}
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@ public class CocoaMQTT5: NSObject, CocoaMQTT5Client {
fileprivate func send(_ frame: Frame, tag: Int = 0) {
printDebug("SEND: \(frame)")
let data = frame.bytes(version: version)


socket.write(Data(bytes: data, count: data.count), withTimeout: 5, tag: tag)
}
Expand Down Expand Up @@ -449,7 +449,7 @@ public class CocoaMQTT5: NSObject, CocoaMQTT5Client {
/// - -1 will be returned, if the messages queue is full
@discardableResult
public func publish(_ topic: String, withString string: String, qos: CocoaMQTTQoS = .qos1, DUP: Bool = false
, retained: Bool = false, properties: MqttPublishProperties) -> Int {
, retained: Bool = false, properties: MqttPublishProperties) -> Int {
let message = CocoaMQTT5Message(topic: topic, string: string, qos: qos, retained: retained)
return publish(message, DUP: DUP, retained: retained, properties: properties)
}
Expand Down Expand Up @@ -589,8 +589,8 @@ extension CocoaMQTT5: CocoaMQTTSocketDelegate {
}

public func socket(_ socket: CocoaMQTTSocketProtocol,
didReceive trust: SecTrust,
completionHandler: @escaping (Bool) -> Swift.Void) {
didReceive trust: SecTrust,
completionHandler: @escaping (Bool) -> Swift.Void) {

printDebug("Call the SSL/TLS manually validating function")

Expand Down Expand Up @@ -627,7 +627,7 @@ extension CocoaMQTT5: CocoaMQTTSocketDelegate {
// Clean up
socket.setDelegate(nil, delegateQueue: nil)
connState = .disconnected

delegate?.mqtt5DidDisconnect(self, withError: err)
didDisconnect(self, err)

Expand Down
1 change: 0 additions & 1 deletion Source/CocoaMQTTMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// MQTT Message
public class CocoaMQTTMessage: NSObject {

Expand Down
1 change: 0 additions & 1 deletion Source/CocoaMQTTProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


public enum CocoaMQTTPropertyName: UInt8 {
case payloadFormatIndicator = 0x01
case willExpiryInterval = 0x02
Expand Down
1 change: 0 additions & 1 deletion Source/CocoaMQTTTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// Encode and Decode big-endian UInt16
extension UInt16 {
/// Most Significant Byte (MSB)
Expand Down
1 change: 0 additions & 1 deletion Source/Frame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// Quality of Service levels
@objc public enum CocoaMQTTQoS: UInt8, CustomStringConvertible {
/// At most once delivery
Expand Down
1 change: 0 additions & 1 deletion Source/FrameAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


struct FrameAuth: Frame {

var packetFixedHeaderType: UInt8 = FrameType.auth.rawValue
Expand Down
1 change: 0 additions & 1 deletion Source/FrameConnAck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


struct FrameConnAck: Frame {

var packetFixedHeaderType: UInt8 = FrameType.connack.rawValue
Expand Down
1 change: 0 additions & 1 deletion Source/FrameDisconnect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// MQTT Disconnect packet
struct FrameDisconnect: Frame {

Expand Down
1 change: 0 additions & 1 deletion Source/FramePingResp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// MQTT PINGRESP packet
struct FramePingResp: Frame {

Expand Down
1 change: 0 additions & 1 deletion Source/FramePubAck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// MQTT PUBACK packet
struct FramePubAck: Frame {

Expand Down
1 change: 0 additions & 1 deletion Source/FrameSubAck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// MQTT SUBACK packet
struct FrameSubAck: Frame {

Expand Down
1 change: 0 additions & 1 deletion Source/FrameSubscribe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// MQTT SUBSCRIBE Frame
struct FrameSubscribe: Frame {

Expand Down
1 change: 0 additions & 1 deletion Source/FrameUnsubscribe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


/// MQTT UNSUBSCRIBE packet
struct FrameUnsubscribe: Frame {

Expand Down
1 change: 1 addition & 0 deletions Source/MqttAuthProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by liwei wang on 1/9/2021.
//

import Foundation

public class MqttAuthProperties: NSObject {

Expand Down
12 changes: 0 additions & 12 deletions Source/MqttDecodeConnAck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


public class MqttDecodeConnAck: NSObject {

// var connackData: [UInt8]
Expand Down Expand Up @@ -65,7 +64,6 @@ public class MqttDecodeConnAck: NSObject {
let occupyIndex = index

// properties

while index - occupyIndex < propertyLength! {
let resVariableByteInteger = decodeVariableByteInteger(data: connackData, offset: index)
index = resVariableByteInteger.newOffset
Expand All @@ -77,16 +75,12 @@ public class MqttDecodeConnAck: NSObject {
switch propertyName.rawValue {

case CocoaMQTTPropertyName.sessionExpiryInterval.rawValue:
// sessionExpiryInterval = UInt32(integerCompute(data: connackData, formatType: formatInt.formatUint32.rawValue, offset: index)!)
// index += 4

let comRes = integerCompute(data: connackData, formatType: formatInt.formatUint32.rawValue, offset: index)
sessionExpiryInterval = UInt32(comRes!.res)
index = comRes!.newOffset

case CocoaMQTTPropertyName.receiveMaximum.rawValue:
// receiveMaximum = UInt16(integerCompute(data: connackData, formatType: formatInt.formatUint16.rawValue, offset: index)!)
// index += 2

let comRes = integerCompute(data: connackData, formatType: formatInt.formatUint16.rawValue, offset: index)
receiveMaximum = UInt16(comRes!.res)
Expand Down Expand Up @@ -117,8 +111,6 @@ public class MqttDecodeConnAck: NSObject {
index += 1

case CocoaMQTTPropertyName.maximumPacketSize.rawValue:
// maximumPacketSize = UInt32(integerCompute(data: connackData, formatType: formatInt.formatUint32.rawValue, offset: index)!)
// index += 4

let comRes = integerCompute(data: connackData, formatType: formatInt.formatUint32.rawValue, offset: index)
maximumPacketSize = UInt32(comRes!.res)
Expand All @@ -132,8 +124,6 @@ public class MqttDecodeConnAck: NSObject {
index = result.newOffset

case CocoaMQTTPropertyName.topicAliasMaximum.rawValue:
// topicAliasMaximum = UInt16(integerCompute(data: connackData, formatType: formatInt.formatUint16.rawValue, offset: index)!)
// index += 2

let comRes = integerCompute(data: connackData, formatType: formatInt.formatUint16.rawValue, offset: index)
topicAliasMaximum = UInt16(comRes!.res)
Expand Down Expand Up @@ -197,8 +187,6 @@ public class MqttDecodeConnAck: NSObject {
index += 1

case CocoaMQTTPropertyName.serverKeepAlive.rawValue:
// serverKeepAlive = UInt16(integerCompute(data: connackData, formatType: formatInt.formatUint16.rawValue, offset: index)!)
// index += 2

let comRes = integerCompute(data: connackData, formatType: formatInt.formatUint16.rawValue, offset: index)
serverKeepAlive = UInt16(comRes!.res)
Expand Down
1 change: 0 additions & 1 deletion Source/MqttDecodePubAck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


public class MqttDecodePubAck: NSObject {

var totalCount = 0
Expand Down
1 change: 0 additions & 1 deletion Source/MqttDecodePubComp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


public class MqttDecodePubComp: NSObject {

var totalCount = 0
Expand Down
1 change: 0 additions & 1 deletion Source/MqttDecodePubRel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


public class MqttDecodePubRel: NSObject {

var totalCount = 0
Expand Down
1 change: 0 additions & 1 deletion Source/MqttDecodeSubAck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


public class MqttDecodeSubAck: NSObject {

var totalCount = 0
Expand Down
1 change: 0 additions & 1 deletion Source/MqttDecodeUnsubAck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


public class MqttDecodeUnsubAck: NSObject {

var totalCount = 0
Expand Down
1 change: 0 additions & 1 deletion Source/MqttPublishProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation


public class MqttPublishProperties: NSObject {


Expand Down
4 changes: 1 addition & 3 deletions Source/MqttSubscription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MqttSubscription {
case .qos2:
options = options | 0b0000_0010
default:
printDebug("topucFilter qos failure")
printDebug("topicFilter qos failure")
}

switch noLocal {
Expand All @@ -63,8 +63,6 @@ public class MqttSubscription {
options = options | 0b0001_0000
case CocoaRetainHandlingOption.sendOnSubscribe:
options = options | 0b0010_0000
// default:
// printDebug("topucFilter retainHandling failure")
}


Expand Down

0 comments on commit e7e8992

Please sign in to comment.