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);
|
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);
|
||||||
|
|
|
@ -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,20 +65,22 @@ 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) {
|
||||||
transportManager = JingleTransportMethodManager.getInstanceFor(connection)
|
throw new IllegalStateException("This session is not fresh.");
|
||||||
.getBestAvailableTransportManager();
|
|
||||||
|
|
||||||
if (transportManager == null) {
|
|
||||||
throw new IllegalStateException("There must be at least one workable transport method.");
|
|
||||||
}
|
|
||||||
|
|
||||||
transport = transportManager.createTransport(getResponder());
|
|
||||||
|
|
||||||
jutil.sendSessionInitiateFileOffer(getResponder(), getSessionId(), creator, name, file, transport);
|
|
||||||
state = State.pending;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transportManager = JingleTransportMethodManager.getInstanceFor(connection)
|
||||||
|
.getBestAvailableTransportManager();
|
||||||
|
|
||||||
|
if (transportManager == null) {
|
||||||
|
throw new IllegalStateException("There must be at least one workable transport method.");
|
||||||
|
}
|
||||||
|
|
||||||
|
transport = transportManager.createTransport(getResponder());
|
||||||
|
|
||||||
|
jutil.sendSessionInitiateFileOffer(getResponder(), getSessionId(), creator, name, file, transport);
|
||||||
|
state = State.pending;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,24 +88,22 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
|
||||||
// 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;
|
|
||||||
transportManager.initiateOutgoingSession(getResponder(), transport, new JingleTransportInitiationCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSessionInitiated(final BytestreamSession session) {
|
|
||||||
sendingThread = new SendingThread(session, source);
|
|
||||||
sendingThread.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
state = State.active;
|
||||||
public void onException(Exception e) {
|
transportManager.initiateOutgoingSession(getResponder(), transport, new JingleTransportInitiationCallback() {
|
||||||
LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e);
|
@Override
|
||||||
}
|
public void onSessionInitiated(final BytestreamSession session) {
|
||||||
});
|
sendingThread = new SendingThread(session, source);
|
||||||
}
|
sendingThread.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onException(Exception e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return jutil.createAck(sessionAccept);
|
return jutil.createAck(sessionAccept);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue