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

Some improvements

This commit is contained in:
vanitasvitae 2017-06-21 15:54:20 +02:00
parent ecd29a1ea8
commit 7f04265bb9
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 32 additions and 32 deletions

View file

@ -77,11 +77,12 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
this.transportManager = tm.getTransportManager(initiate); this.transportManager = tm.getTransportManager(initiate);
if (transportManager == null) { if (transportManager == null) {
//Fallback //Try fallback.
pendingSessionInitiate = initiate; pendingSessionInitiate = initiate;
transportManager = tm.getBestAvailableTransportManager(); transportManager = tm.getBestAvailableTransportManager();
if (transportManager == null) { if (transportManager == null) {
//No usable transports.
jutil.sendSessionTerminateUnsupportedTransports(initiate.getInitiator(), initiate.getSid()); jutil.sendSessionTerminateUnsupportedTransports(initiate.getInitiator(), initiate.getSid());
state = State.terminated; state = State.terminated;
return jutil.createAck(initiate); return jutil.createAck(initiate);

View file

@ -49,8 +49,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
sent_transport_replace, sent_transport_replace,
active, active,
terminated, terminated,
; ;}
}
private Thread sendingThread; private Thread sendingThread;
private File source; private File source;
@ -66,8 +65,11 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
this(connection, recipient, JingleManager.randomSid()); this(connection, recipient, JingleManager.randomSid());
} }
public void sendFile(JingleFileTransfer file, JingleContent.Creator creator, String name) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { public void initiateFileOffer(JingleFileTransfer file, JingleContent.Creator creator, String name) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
if (state == State.fresh) { if (state != State.fresh) {
throw new IllegalStateException("This session is not fresh.");
}
transportManager = JingleTransportMethodManager.getInstanceFor(connection) transportManager = JingleTransportMethodManager.getInstanceFor(connection)
.getBestAvailableTransportManager(); .getBestAvailableTransportManager();
@ -80,17 +82,15 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
jutil.sendSessionInitiateFileOffer(getResponder(), getSessionId(), creator, name, file, transport); jutil.sendSessionInitiateFileOffer(getResponder(), getSessionId(), creator, name, file, transport);
state = State.pending; state = State.pending;
} }
}
@Override @Override
public IQ handleSessionAccept(Jingle sessionAccept) throws SmackException.NotConnectedException, InterruptedException { public IQ handleSessionAccept(Jingle sessionAccept) throws SmackException.NotConnectedException, InterruptedException {
// Out of order? // Out of order?
if (state != State.pending) { if (state != State.pending) {
LOGGER.log(Level.WARNING, "Out of order!"); LOGGER.log(Level.WARNING, "Out of order!");
jutil.sendErrorOutOfOrder(sessionAccept); return jutil.createErrorOutOfOrder(sessionAccept);
} }
// Legal
else {
state = State.active; state = State.active;
transportManager.initiateOutgoingSession(getResponder(), transport, new JingleTransportInitiationCallback() { transportManager.initiateOutgoingSession(getResponder(), transport, new JingleTransportInitiationCallback() {
@Override @Override
@ -104,7 +104,6 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e); LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e);
} }
}); });
}
return jutil.createAck(sessionAccept); return jutil.createAck(sessionAccept);
} }