If after ‘connection_ack’ server sends me ‘ka’ message, my messages can’t be sent (-> subscription can't be made), because in method write(_ str: String, force forced: Bool = false, id : Int? = nil) field ‘acked’ of class WebSocketTransport will never be ‘true’. My though is: ‘ka’ message shouldn’t reset acked property.
In WebSocketTransport class:
So here is why acked field resets to "false" after "ka" message arrived
case OperationMessage.Types.CONNECTION_ACK.rawValue,
OperationMessage.Types.CONNECTION_KEEP_ALIVE.rawValue:
acked = (type == OperationMessage.Types.CONNECTION_ACK.rawValue)
And then we never can't make websocket.write() here
private func write(_ str: String, force forced: Bool = false, id : Int? = nil) {
print("WebSocket: write: forced \(forced) acked \(acked) \n\(str) ")
if let websocket = websocket {
if websocket.isConnected && (acked || forced) {
websocket.write(string: str)
} else {
// using sequence number to make sure that the queue is processed correctly
// either using the earlier assigned id or with the next higher key
if let id = id {
queue[id] = str
} else if let id = queue.keys.max() {
queue[id+1] = str
} else {
queue[1] = str
}
}
}
}
My thoughts is doing like so instead of first code chunk:
case OperationMessage.Types.CONNECTION_ACK.rawValue:
acked = true
writeQueue()
case OperationMessage.Types.CONNECTION_KEEP_ALIVE.rawValue:
writeQueue()
If after ‘connection_ack’ server sends me ‘ka’ message, my messages can’t be sent (-> subscription can't be made), because in method
write(_ str: String, force forced: Bool = false, id : Int? = nil)field ‘acked’ of classWebSocketTransportwill never be ‘true’. My though is: ‘ka’ message shouldn’t resetackedproperty.In
WebSocketTransportclass:So here is why
ackedfield resets to "false" after "ka" message arrivedAnd then we never can't make
websocket.write()hereMy thoughts is doing like so instead of first code chunk: