CarrotChat v2.8.80.240429版本的 MD5 值为:fdf98761f01e715a89df24b85b0d206e
以下内容为反编译后的 InitiationListener.java 源代码,内容仅作参考
package org.jivesoftware.smackx.bytestreams.ibb;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
import org.jivesoftware.smackx.filetransfer.StreamNegotiator;
public class InitiationListener extends AbstractIqRequestHandler {
private static final Logger LOGGER = Logger.getLogger(InitiationListener.class.getName());
private final ExecutorService initiationListenerExecutor;
private final InBandBytestreamManager manager;
public InitiationListener(InBandBytestreamManager inBandBytestreamManager) {
super("open", "http://jabber.org/protocol/ibb", IQ.Type.set, IQRequestHandler.Mode.async);
this.manager = inBandBytestreamManager;
this.initiationListenerExecutor = Executors.newCachedThreadPool();
}
public void processRequest(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException {
Open open = (Open) stanza;
if (open.getBlockSize() > this.manager.getMaximumBlockSize()) {
this.manager.replyResourceConstraintPacket(open);
return;
}
StreamNegotiator.signal(open.getFrom().toString() + '\t' + open.getSessionID(), open);
if (this.manager.getIgnoredBytestreamRequests().remove(open.getSessionID())) {
return;
}
InBandBytestreamRequest inBandBytestreamRequest = new InBandBytestreamRequest(this.manager, open);
BytestreamListener userListener = this.manager.getUserListener(open.getFrom());
if (userListener != null) {
userListener.incomingBytestreamRequest(inBandBytestreamRequest);
} else {
if (!this.manager.getAllRequestListeners().isEmpty()) {
Iterator<BytestreamListener> it = this.manager.getAllRequestListeners().iterator();
while (it.hasNext()) {
it.next().incomingBytestreamRequest(inBandBytestreamRequest);
}
return;
}
this.manager.replyRejectPacket(open);
}
}
@Override
public IQ handleIQRequest(final IQ iq) {
this.initiationListenerExecutor.execute(new Runnable() {
@Override
public void run() {
try {
InitiationListener.this.processRequest(iq);
} catch (InterruptedException | SmackException.NotConnectedException e10) {
InitiationListener.LOGGER.log(Level.WARNING, "proccessRequest", e10);
}
}
});
return null;
}
public void shutdown() {
this.initiationListenerExecutor.shutdownNow();
}
}