1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 20:42:06 +01:00

Some debug output and small fixes

This commit is contained in:
vanitasvitae 2017-06-27 20:27:38 +02:00
parent 9d6a858b23
commit 3058ebe8b9
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 17 additions and 11 deletions

View file

@ -143,6 +143,15 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
state = State.active;
try {
jutil.sendSessionAccept(getInitiator(), sid, getContents().get(0).getCreator(),
getContents().get(0).getName(), JingleContent.Senders.initiator, file,
transportSession.createTransport());
} catch (SmackException.NotConnectedException | SmackException.NoResponseException |
XMPPException.XMPPErrorException | InterruptedException e) {
LOGGER.log(Level.WARNING, "Could not send session-accept.", e);
}
transportSession.initiateIncomingSession(new JingleTransportInitiationCallback() {
@Override
public void onSessionInitiated(BytestreamSession bytestreamSession) {
@ -153,18 +162,9 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
@Override
public void onException(Exception e) {
LOGGER.log(Level.SEVERE, "EXCEPTION IN INCOMING SESSION: ", e);
}
});
try {
jutil.sendSessionAccept(getInitiator(), sid, getContents().get(0).getCreator(),
getContents().get(0).getName(), JingleContent.Senders.initiator, file,
transportSession.createTransport());
} catch (SmackException.NotConnectedException | SmackException.NoResponseException |
XMPPException.XMPPErrorException | InterruptedException e) {
LOGGER.log(Level.WARNING, "Could not send session-accept.", e);
}
}
@Override

View file

@ -119,7 +119,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
@Override
public void onException(Exception e) {
LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e);
LOGGER.log(Level.SEVERE, "EXCEPTION IN OUTGOING SESSION:", e);
}
});

View file

@ -45,6 +45,7 @@ public class ReceiveTask implements Runnable {
@Override
public void run() {
LOGGER.log(Level.INFO, "Start ReceiveTask");
JingleFileTransferChild transfer = (JingleFileTransferChild) fileTransfer.getJingleContentDescriptionChildren().get(0);
FileOutputStream outputStream = null;
InputStream inputStream;
@ -68,12 +69,14 @@ public class ReceiveTask implements Runnable {
}
outputStream.write(filebuf);
LOGGER.log(Level.INFO, "Received " + read + " bytes.");
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error while receiving data: ", e);
} finally {
try {
session.close();
LOGGER.log(Level.INFO, "Session closed.");
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not close InputStream.", e);
}

View file

@ -42,6 +42,7 @@ public class SendTask implements Runnable {
@Override
public void run() {
LOGGER.log(Level.INFO, "Start SendTask");
InputStream inputStream;
OutputStream outputStream;
@ -57,6 +58,7 @@ public class SendTask implements Runnable {
}
outputStream.write(filebuf);
LOGGER.log(Level.INFO, "Written " + r + " bytes.");
}
catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not send file: " + e, e);
@ -64,6 +66,7 @@ public class SendTask implements Runnable {
finally {
try {
session.close();
LOGGER.log(Level.INFO, "Session closed.");
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not close session.", e);
}