Hi,
I would like to ask you for help. In my bachelor thesis I am using smack together with OpenFire. I need to accept any incoming file and store it in dir xml/. But only thing what happen is, that client start negotiating transfer, after that stream and after that fails. on the other side I am using pidgin to send files and pidgin say, that he is waiting for transfer beginning.
Here I enclose another information:
Version of Smack: 4.0.7
I enclosed debug incoming and outcoming packets in log
Here is output of my code:
Žádost o transfer (transfer request)
Jméno souboru: sada2příklad4.pdf (name of file)
posílání dat (sending data)
Initial
0.0
Negotiating Transfer
0.0
Negotiating Stream
0.0
Negotiating Stream
0.0
Negotiating Stream
0.0
Negotiating Stream
0.0
Negotiating Stream
0.0
Přenos zkončil (transfer ended)
Here is my handleFile function
private void handleFile(){
final FileTransferManager manager = new FileTransferManager(connection);
FileTransferNegotiator.setServiceEnabled(connection, true);
manager.addFileTransferListener(new FileTransferListener() {
@Override
public void fileTransferRequest(FileTransferRequest request) {
if(request != null){
try {
System.out.println(“Žádost o transfer”);
final IncomingFileTransfer transfer = request.accept();
System.out.println("Jméno souboru: " + request.getFileName());
String path = “./xml/”+ request.getFileName();
System.out.println("Výsledná cesta k souboru: " + path);
transfer.recieveFile(new File(path));
System.out.println(“posílání dat”);
System.out.println(transfer.getStatus());
System.out.println(transfer.getProgress());
Thread thread = new Thread(){
@Override
public void run(){
while(!transfer.isDone()) {
try {
if(transfer.getStatus().equals(Status.error)) {
System.out.println("ERROR!!! " + transfer.getError());
} else {
System.out.println(transfer.getStatus());
System.out.println(transfer.getProgress());
}
sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(AdminAgent.class.getName()).log(Level.SEVERE, null, ex);
}
}
System.out.println(“Přenos zkončil”);
}
};
thread.start();
} catch (SmackException ex) {
Logger.getLogger(AdminAgent.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
System.out.println(“Inicializovaný chat”);
}
I really don’t know how to make it work and I would really appreciate any help.
Best regards
Jakub Peschel
log.zip (1741 Bytes)