If user1 creates an OutgoingFileTransfer and calls the sendFile(File file, String description) method on it to send the file to user2; if user2 rejects the transfer, how does user1 can handle this event?
You can just check if the status is REFUSED with something like this:
FileTransferManager manager = new FileTransferManager(conn);
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer("user@domian/resource");
try {
transfer.sendFile(new File("c:/testSend.txt";), "Testing a file");
while(!transfer.isDone()) {
if (transfer.getStatus().equals(Status.REFUSED)) {
//Don''t forget this break
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} catch (XMPPException e) {
e.printStackTrace();
}
I think there’'s no event that you can listen to.
Another thing is that you must check the REFUSED inside the “while is not done” and “break” the iteration because the isDone still false when the status is REFUSED, otherwise the iteration will never end. I mean