call current transport when receiving transport-replace
This commit is contained in:
parent
15a3c163eb
commit
b2e1f9b3d8
|
@ -212,7 +212,6 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
jinglePacket.setSecurity(
|
jinglePacket.setSecurity(
|
||||||
Iterables.getOnlyElement(contentMap.contents.keySet()), xmppAxolotlMessage);
|
Iterables.getOnlyElement(contentMap.contents.keySet()), xmppAxolotlMessage);
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "--> " + jinglePacket.toString());
|
|
||||||
jinglePacket.setTo(id.with);
|
jinglePacket.setTo(id.with);
|
||||||
xmppConnectionService.sendIqPacket(
|
xmppConnectionService.sendIqPacket(
|
||||||
id.account,
|
id.account,
|
||||||
|
@ -235,7 +234,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
private void receiveSessionAccept(final JinglePacket jinglePacket) {
|
private void receiveSessionAccept(final JinglePacket jinglePacket) {
|
||||||
Log.d(Config.LOGTAG, "receive session accept " + jinglePacket);
|
Log.d(Config.LOGTAG, "receive file transfer session accept");
|
||||||
if (isResponder()) {
|
if (isResponder()) {
|
||||||
receiveOutOfOrderAction(jinglePacket, JinglePacket.Action.SESSION_ACCEPT);
|
receiveOutOfOrderAction(jinglePacket, JinglePacket.Action.SESSION_ACCEPT);
|
||||||
return;
|
return;
|
||||||
|
@ -450,7 +449,6 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
setLocalContentMap(contentMap);
|
setLocalContentMap(contentMap);
|
||||||
final var jinglePacket =
|
final var jinglePacket =
|
||||||
contentMap.toJinglePacket(JinglePacket.Action.SESSION_ACCEPT, id.sessionId);
|
contentMap.toJinglePacket(JinglePacket.Action.SESSION_ACCEPT, id.sessionId);
|
||||||
Log.d(Config.LOGTAG, "--> " + jinglePacket.toString());
|
|
||||||
send(jinglePacket);
|
send(jinglePacket);
|
||||||
// this needs to come after session-accept or else our candidate-error might arrive first
|
// this needs to come after session-accept or else our candidate-error might arrive first
|
||||||
this.transport.connect();
|
this.transport.connect();
|
||||||
|
@ -537,7 +535,6 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
private void receiveSessionInfo(final JinglePacket jinglePacket) {
|
private void receiveSessionInfo(final JinglePacket jinglePacket) {
|
||||||
Log.d(Config.LOGTAG, "<-- " + jinglePacket);
|
|
||||||
respondOk(jinglePacket);
|
respondOk(jinglePacket);
|
||||||
final var sessionInfo = FileTransferDescription.getSessionInfo(jinglePacket);
|
final var sessionInfo = FileTransferDescription.getSessionInfo(jinglePacket);
|
||||||
if (sessionInfo instanceof FileTransferDescription.Checksum checksum) {
|
if (sessionInfo instanceof FileTransferDescription.Checksum checksum) {
|
||||||
|
@ -723,7 +720,6 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
receiveOutOfOrderAction(jinglePacket, JinglePacket.Action.TRANSPORT_REPLACE);
|
receiveOutOfOrderAction(jinglePacket, JinglePacket.Action.TRANSPORT_REPLACE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "receive transport replace " + jinglePacket);
|
|
||||||
final GenericTransportInfo transportInfo;
|
final GenericTransportInfo transportInfo;
|
||||||
try {
|
try {
|
||||||
transportInfo = FileTransferContentMap.of(jinglePacket).requireOnlyTransportInfo();
|
transportInfo = FileTransferContentMap.of(jinglePacket).requireOnlyTransportInfo();
|
||||||
|
@ -746,7 +742,16 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
private void receiveTransportReplace(
|
private void receiveTransportReplace(
|
||||||
final JinglePacket jinglePacket, final GenericTransportInfo transportInfo) {
|
final JinglePacket jinglePacket, final GenericTransportInfo transportInfo) {
|
||||||
respondOk(jinglePacket);
|
respondOk(jinglePacket);
|
||||||
// TODO kill current transport
|
final Transport currentTransport = this.transport;
|
||||||
|
if (currentTransport != null) {
|
||||||
|
Log.d(
|
||||||
|
Config.LOGTAG,
|
||||||
|
"terminating "
|
||||||
|
+ currentTransport.getClass().getSimpleName()
|
||||||
|
+ " upon receiving transport-replace");
|
||||||
|
currentTransport.setTransportCallback(null);
|
||||||
|
currentTransport.terminate();
|
||||||
|
}
|
||||||
final Transport nextTransport;
|
final Transport nextTransport;
|
||||||
try {
|
try {
|
||||||
nextTransport = setupTransport(transportInfo);
|
nextTransport = setupTransport(transportInfo);
|
||||||
|
@ -755,6 +760,9 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.transport = nextTransport;
|
this.transport = nextTransport;
|
||||||
|
Log.d(
|
||||||
|
Config.LOGTAG,
|
||||||
|
"replacing transport with " + nextTransport.getClass().getSimpleName());
|
||||||
this.transport.setTransportCallback(this);
|
this.transport.setTransportCallback(this);
|
||||||
final var transportInfoFuture = nextTransport.asTransportInfo();
|
final var transportInfoFuture = nextTransport.asTransportInfo();
|
||||||
Futures.addCallback(
|
Futures.addCallback(
|
||||||
|
@ -781,7 +789,6 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
contentMap
|
contentMap
|
||||||
.transportInfo()
|
.transportInfo()
|
||||||
.toJinglePacket(JinglePacket.Action.TRANSPORT_ACCEPT, id.sessionId);
|
.toJinglePacket(JinglePacket.Action.TRANSPORT_ACCEPT, id.sessionId);
|
||||||
Log.d(Config.LOGTAG, "sending transport accept " + jinglePacket);
|
|
||||||
send(jinglePacket);
|
send(jinglePacket);
|
||||||
transport.connect();
|
transport.connect();
|
||||||
}
|
}
|
||||||
|
@ -961,7 +968,6 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
new JinglePacket(JinglePacket.Action.SESSION_INFO, this.id.sessionId);
|
new JinglePacket(JinglePacket.Action.SESSION_INFO, this.id.sessionId);
|
||||||
jinglePacket.addJingleChild(sessionInfo.asElement());
|
jinglePacket.addJingleChild(sessionInfo.asElement());
|
||||||
jinglePacket.setTo(this.id.with);
|
jinglePacket.setTo(this.id.with);
|
||||||
Log.d(Config.LOGTAG, "--> " + jinglePacket);
|
|
||||||
send(jinglePacket);
|
send(jinglePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -984,6 +990,9 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
transport.terminate();
|
transport.terminate();
|
||||||
if (isInitiator()) {
|
if (isInitiator()) {
|
||||||
this.transport = setupLastResortTransport();
|
this.transport = setupLastResortTransport();
|
||||||
|
Log.d(
|
||||||
|
Config.LOGTAG,
|
||||||
|
"replacing transport with " + this.transport.getClass().getSimpleName());
|
||||||
this.transport.setTransportCallback(this);
|
this.transport.setTransportCallback(this);
|
||||||
final var transportInfoFuture = this.transport.asTransportInfo();
|
final var transportInfoFuture = this.transport.asTransportInfo();
|
||||||
Futures.addCallback(
|
Futures.addCallback(
|
||||||
|
@ -1013,7 +1022,6 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
contentMap
|
contentMap
|
||||||
.transportInfo()
|
.transportInfo()
|
||||||
.toJinglePacket(JinglePacket.Action.TRANSPORT_REPLACE, id.sessionId);
|
.toJinglePacket(JinglePacket.Action.TRANSPORT_REPLACE, id.sessionId);
|
||||||
Log.d(Config.LOGTAG, "sending transport replace " + jinglePacket);
|
|
||||||
send(jinglePacket);
|
send(jinglePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,7 +1049,6 @@ public class JingleFileTransferConnection extends AbstractJingleConnection
|
||||||
}
|
}
|
||||||
final JinglePacket jinglePacket =
|
final JinglePacket jinglePacket =
|
||||||
transportInfo.toJinglePacket(JinglePacket.Action.TRANSPORT_INFO, id.sessionId);
|
transportInfo.toJinglePacket(JinglePacket.Action.TRANSPORT_INFO, id.sessionId);
|
||||||
Log.d(Config.LOGTAG, "--> " + jinglePacket);
|
|
||||||
send(jinglePacket);
|
send(jinglePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,14 @@ public class WebRTCDataChannelTransport implements Transport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onIceConnectionFailed() {
|
private void onIceConnectionFailed() {
|
||||||
this.transportCallback.onTransportSetupFailed();
|
final var callback = this.transportCallback;
|
||||||
|
if (callback == null) {
|
||||||
|
Log.d(
|
||||||
|
Config.LOGTAG,
|
||||||
|
"not calling onTransportSetupFailed(). Transport likely has been replaced");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback.onTransportSetupFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDataChannel(final DataChannel dataChannel) {
|
private void setDataChannel(final DataChannel dataChannel) {
|
||||||
|
|
Loading…
Reference in a new issue