mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
SMACK-129 - Added a property in smack-config file for the default packet collector size and set it much lower than the previous default. Also made the max size for packet collectors configurable from the constructor.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_2_0@12509 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
0c88e19d3b
commit
da5434505b
5 changed files with 97 additions and 15 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
@ -38,7 +39,7 @@ class ConnectionDetachedPacketCollector {
|
|||
* reached, older packets will be automatically dropped from the queue as
|
||||
* new packets are added.
|
||||
*/
|
||||
private static final int MAX_PACKETS = 65536;
|
||||
private int maxPackets = SmackConfiguration.getPacketCollectorSize();
|
||||
|
||||
private LinkedList<Packet> resultQueue;
|
||||
|
||||
|
@ -50,6 +51,15 @@ class ConnectionDetachedPacketCollector {
|
|||
this.resultQueue = new LinkedList<Packet>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new packet collector. If the packet filter is <tt>null</tt>, then
|
||||
* all packets will match this collector.
|
||||
*/
|
||||
public ConnectionDetachedPacketCollector(int maxSize) {
|
||||
this.resultQueue = new LinkedList<Packet>();
|
||||
maxPackets = maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Polls to see if a packet is currently available and returns it, or
|
||||
* immediately returns <tt>null</tt> if no packets are currently in the
|
||||
|
@ -124,7 +134,7 @@ class ConnectionDetachedPacketCollector {
|
|||
return;
|
||||
}
|
||||
// If the max number of packets has been reached, remove the oldest one.
|
||||
if (resultQueue.size() == MAX_PACKETS) {
|
||||
if (resultQueue.size() == maxPackets) {
|
||||
resultQueue.removeLast();
|
||||
}
|
||||
// Add the new packet.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue