Massive refactoring to merge handling of simplex and duplex connections.

This commit is contained in:
akwizgran
2014-11-04 16:51:25 +00:00
parent b24f153704
commit 7b8181e309
67 changed files with 1981 additions and 2288 deletions

View File

@@ -75,8 +75,8 @@ class AliceConnector extends Connector {
Writer w;
byte[] secret;
try {
in = conn.getInputStream();
out = conn.getOutputStream();
in = conn.getReader().getInputStream();
out = conn.getWriter().getOutputStream();
r = readerFactory.createReader(in);
w = writerFactory.createWriter(out);
// Alice goes first
@@ -130,7 +130,7 @@ class AliceConnector extends Connector {
// Confirmation succeeded - upgrade to a secure connection
if(LOG.isLoggable(INFO))
LOG.info(pluginName + " confirmation succeeded");
int maxFrameLength = conn.getMaxFrameLength();
int maxFrameLength = conn.getReader().getMaxFrameLength();
StreamReader streamReader =
streamReaderFactory.createInvitationStreamReader(in,
maxFrameLength, secret, false);

View File

@@ -69,8 +69,8 @@ class BobConnector extends Connector {
Writer w;
byte[] secret;
try {
in = conn.getInputStream();
out = conn.getOutputStream();
in = conn.getReader().getInputStream();
out = conn.getWriter().getOutputStream();
r = readerFactory.createReader(in);
w = writerFactory.createWriter(out);
// Alice goes first
@@ -130,7 +130,7 @@ class BobConnector extends Connector {
// Confirmation succeeded - upgrade to a secure connection
if(LOG.isLoggable(INFO))
LOG.info(pluginName + " confirmation succeeded");
int maxFrameLength = conn.getMaxFrameLength();
int maxFrameLength = conn.getReader().getMaxFrameLength();
StreamReader streamReader =
streamReaderFactory.createInvitationStreamReader(in,
maxFrameLength, secret, true);

View File

@@ -311,7 +311,8 @@ abstract class Connector extends Thread {
boolean exception) {
try {
LOG.info("Closing connection");
conn.dispose(exception, true);
conn.getReader().dispose(exception, true);
conn.getWriter().dispose(exception);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}