mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Some improvements
This commit is contained in:
parent
ecd29a1ea8
commit
7f04265bb9
2 changed files with 32 additions and 32 deletions
|
@ -77,11 +77,12 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
|
|||
this.transportManager = tm.getTransportManager(initiate);
|
||||
|
||||
if (transportManager == null) {
|
||||
//Fallback
|
||||
//Try fallback.
|
||||
pendingSessionInitiate = initiate;
|
||||
transportManager = tm.getBestAvailableTransportManager();
|
||||
|
||||
if (transportManager == null) {
|
||||
//No usable transports.
|
||||
jutil.sendSessionTerminateUnsupportedTransports(initiate.getInitiator(), initiate.getSid());
|
||||
state = State.terminated;
|
||||
return jutil.createAck(initiate);
|
||||
|
|
|
@ -49,8 +49,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
|||
sent_transport_replace,
|
||||
active,
|
||||
terminated,
|
||||
;
|
||||
}
|
||||
;}
|
||||
|
||||
private Thread sendingThread;
|
||||
private File source;
|
||||
|
@ -66,8 +65,11 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
|||
this(connection, recipient, JingleManager.randomSid());
|
||||
}
|
||||
|
||||
public void sendFile(JingleFileTransfer file, JingleContent.Creator creator, String name) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||
if (state == State.fresh) {
|
||||
public void initiateFileOffer(JingleFileTransfer file, JingleContent.Creator creator, String name) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
|
||||
if (state != State.fresh) {
|
||||
throw new IllegalStateException("This session is not fresh.");
|
||||
}
|
||||
|
||||
transportManager = JingleTransportMethodManager.getInstanceFor(connection)
|
||||
.getBestAvailableTransportManager();
|
||||
|
||||
|
@ -80,17 +82,15 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
|||
jutil.sendSessionInitiateFileOffer(getResponder(), getSessionId(), creator, name, file, transport);
|
||||
state = State.pending;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IQ handleSessionAccept(Jingle sessionAccept) throws SmackException.NotConnectedException, InterruptedException {
|
||||
// Out of order?
|
||||
if (state != State.pending) {
|
||||
LOGGER.log(Level.WARNING, "Out of order!");
|
||||
jutil.sendErrorOutOfOrder(sessionAccept);
|
||||
return jutil.createErrorOutOfOrder(sessionAccept);
|
||||
}
|
||||
// Legal
|
||||
else {
|
||||
|
||||
state = State.active;
|
||||
transportManager.initiateOutgoingSession(getResponder(), transport, new JingleTransportInitiationCallback() {
|
||||
@Override
|
||||
|
@ -104,7 +104,6 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
|||
LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return jutil.createAck(sessionAccept);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue