get rid of internal emitAck method
This commit is contained in:
parent
be43b0ab3c
commit
b73afe0da9
@ -289,16 +289,16 @@ open class SocketIOClient : NSObject, SocketIOClientSpec {
|
||||
return createOnAck([event] + items)
|
||||
}
|
||||
|
||||
func emit(_ data: [Any], ack: Int? = nil, binary: Bool = true) {
|
||||
func emit(_ data: [Any], ack: Int? = nil, binary: Bool = true, isAck: Bool = false) {
|
||||
guard status == .connected else {
|
||||
handleClientEvent(.error, data: ["Tried emitting when not connected"])
|
||||
return
|
||||
}
|
||||
|
||||
let packet = SocketPacket.packetFromEmit(data, id: ack ?? -1, nsp: nsp, ack: false, checkForBinary: binary)
|
||||
let packet = SocketPacket.packetFromEmit(data, id: ack ?? -1, nsp: nsp, ack: isAck, checkForBinary: binary)
|
||||
let str = packet.packetString
|
||||
|
||||
DefaultSocketLogger.Logger.log("Emitting: \(str)", type: logType)
|
||||
DefaultSocketLogger.Logger.log("Emitting: \(str), Ack: \(isAck)", type: logType)
|
||||
|
||||
manager?.engine?.send(str, withData: packet.binary)
|
||||
}
|
||||
@ -310,18 +310,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec {
|
||||
/// - parameter ack: The ack number.
|
||||
/// - parameter with: The data for this ack.
|
||||
open func emitAck(_ ack: Int, with items: [Any]) {
|
||||
emitAck(ack, with: items, binary: true)
|
||||
}
|
||||
|
||||
func emitAck(_ ack: Int, with items: [Any], binary: Bool) {
|
||||
guard status == .connected else { return }
|
||||
|
||||
let packet = SocketPacket.packetFromEmit(items, id: ack, nsp: nsp, ack: true, checkForBinary: binary)
|
||||
let str = packet.packetString
|
||||
|
||||
DefaultSocketLogger.Logger.log("Emitting Ack: \(str)", type: logType)
|
||||
|
||||
manager?.engine?.send(str, withData: packet.binary)
|
||||
emit(items, ack: ack, binary: true, isAck: true)
|
||||
}
|
||||
|
||||
/// Called when socket.io has acked one of our emits. Causes the corresponding ack callback to be called.
|
||||
|
||||
@ -150,7 +150,7 @@ public final class SocketRawAckView : NSObject {
|
||||
guard ackNum != -1 else { return }
|
||||
|
||||
do {
|
||||
socket.emitAck(ackNum, with: try items.map({ try $0.socketRepresentation() }), binary: false)
|
||||
socket.emit(try items.map({ try $0.socketRepresentation() }), ack: ackNum, binary: false, isAck: true)
|
||||
} catch let err {
|
||||
socket.handleClientEvent(.error, data: [ackNum, items, err])
|
||||
}
|
||||
@ -163,6 +163,6 @@ public final class SocketRawAckView : NSObject {
|
||||
public func with(_ items: [Any]) {
|
||||
guard ackNum != -1 else { return }
|
||||
|
||||
socket.emitAck(ackNum, with: items, binary: false)
|
||||
socket.emit(items, ack: ackNum, binary: false, isAck: true)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user