Use separate methods for registering incoming and outgoing connections.

This commit is contained in:
akwizgran
2020-06-26 09:59:03 +01:00
parent 95f427863d
commit 7736a3b6fc
5 changed files with 76 additions and 41 deletions

View File

@@ -61,7 +61,25 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
}
@Override
public void registerConnection(ContactId c, TransportId t,
public void registerIncomingConnection(ContactId c, TransportId t,
InterruptibleConnection conn) {
if (LOG.isLoggable(INFO)) {
LOG.info("Incoming connection registered: " + t);
}
registerConnection(c, t, conn, true);
}
@Override
public void registerOutgoingConnection(ContactId c, TransportId t,
InterruptibleConnection conn, Priority priority) {
if (LOG.isLoggable(INFO)) {
LOG.info("Outgoing connection registered: " + t);
}
registerConnection(c, t, conn, false);
setPriority(c, t, conn, priority);
}
private void registerConnection(ContactId c, TransportId t,
InterruptibleConnection conn, boolean incoming) {
if (LOG.isLoggable(INFO)) {
if (incoming) LOG.info("Incoming connection registered: " + t);

View File

@@ -59,8 +59,8 @@ class IncomingDuplexSyncConnection extends DuplexSyncConnection
onReadError(true);
return;
}
connectionRegistry.registerConnection(contactId, transportId,
this, true);
connectionRegistry.registerIncomingConnection(contactId, transportId,
this);
// Start the outgoing session on another thread
ioExecutor.execute(() -> runOutgoingSession(contactId));
try {

View File

@@ -104,9 +104,8 @@ class OutgoingDuplexSyncConnection extends DuplexSyncConnection
onReadError();
return;
}
connectionRegistry.registerConnection(contactId, transportId,
this, false);
connectionRegistry.setPriority(contactId, transportId, this, priority);
connectionRegistry.registerOutgoingConnection(contactId, transportId,
this, priority);
try {
// Store any transport properties discovered from the connection
transportPropertyManager.addRemotePropertiesFromConnection(