这与Android的paho MQTT客户端有关:lazy var searchBar = UISearchBar(frame: CGRect.zero)
override func viewDidLoad() {
tableView.delegate = self
tableView.dataSource = self
searchBar.searchBarStyle = .minimal
navigationItem.titleView = searchBar
}
的Javadoc未指定DisconnectedBufferOptions
的确切行为。如果我将其设置为setDeleteOldestMessages()
,并且消息数量超出缓冲区的容纳范围,结果将是什么?
答案 0 :(得分:0)
/**
* This will add a new message to the offline buffer,
* if the buffer is full and deleteOldestMessages is enabled
* then the 0th item in the buffer will be deleted and the
* new message will be added. If it is not enabled then an
* MqttException will be thrown.
* @param message the {@link MqttWireMessage} that will be buffered
* @param token the associated {@link MqttToken}
* @throws MqttException if the Buffer is full
*/
public void putMessage(MqttWireMessage message, MqttToken token) throws MqttException{
BufferedMessage bufferedMessage = new BufferedMessage(message, token);
synchronized (bufLock) {
if(buffer.size() < bufferOpts.getBufferSize()){
buffer.add(bufferedMessage);
} else if(bufferOpts.isDeleteOldestMessages() == true){
buffer.remove(0);
buffer.add(bufferedMessage);
}else {
throw new MqttException(MqttException.REASON_CODE_DISCONNECTED_BUFFER_FULL);
}
}
}