client demo cleanup

This commit is contained in:
zzz
2015-11-25 14:48:43 +00:00
parent 110a0a1b7a
commit 6081856dd1
4 changed files with 36 additions and 36 deletions

View File

@ -13,13 +13,13 @@ import net.i2p.util.Log;
*/
public class SAMEventHandler extends SAMClientEventListenerImpl {
//private I2PAppContext _context;
private Log _log;
private final Log _log;
private Boolean _helloOk;
private Object _helloLock = new Object();
private final Object _helloLock = new Object();
private Boolean _sessionCreateOk;
private Object _sessionCreateLock = new Object();
private Object _namingReplyLock = new Object();
private Map<String,String> _namingReplies = new HashMap<String,String>();
private final Object _sessionCreateLock = new Object();
private final Object _namingReplyLock = new Object();
private final Map<String,String> _namingReplies = new HashMap<String,String>();
public SAMEventHandler(I2PAppContext ctx) {
//_context = ctx;

View File

@ -16,10 +16,10 @@ import net.i2p.util.Log;
*
*/
public class SAMReader {
private Log _log;
private InputStream _inRaw;
private SAMClientEventListener _listener;
private boolean _live;
private final Log _log;
private final InputStream _inRaw;
private final SAMClientEventListener _listener;
private volatile boolean _live;
public SAMReader(I2PAppContext context, InputStream samIn, SAMClientEventListener listener) {
_log = context.logManager().getLog(SAMReader.class);
@ -32,6 +32,7 @@ public class SAMReader {
I2PAppThread t = new I2PAppThread(new Runner(), "SAM reader");
t.start();
}
public void stopReading() { _live = false; }
/**

View File

@ -20,21 +20,21 @@ import net.i2p.util.Log;
*
*/
public class SAMStreamSend {
private I2PAppContext _context;
private Log _log;
private String _samHost;
private String _samPort;
private String _destFile;
private String _dataFile;
private String _conOptions;
private final I2PAppContext _context;
private final Log _log;
private final String _samHost;
private final String _samPort;
private final String _destFile;
private final String _dataFile;
private final String _conOptions;
private Socket _samSocket;
private OutputStream _samOut;
private InputStream _samIn;
private SAMReader _reader;
//private boolean _dead;
private SAMEventHandler _eventHandler;
private final SAMEventHandler _eventHandler;
/** Connection id (Integer) to peer (Flooder) */
private Map<Integer, Sender> _remotePeers;
private final Map<Integer, Sender> _remotePeers;
public static void main(String args[]) {
if (args.length < 4) {
@ -165,13 +165,11 @@ public class SAMStreamSend {
private int _connectionId;
private String _remoteDestination;
private InputStream _in;
private boolean _closed;
private volatile boolean _closed;
private long _started;
private long _totalSent;
public Sender() {
_closed = false;
}
public Sender() {}
public boolean openConnection() {
FileInputStream fin = null;

View File

@ -20,21 +20,21 @@ import net.i2p.util.Log;
*
*/
public class SAMStreamSink {
private I2PAppContext _context;
private Log _log;
private String _samHost;
private String _samPort;
private String _destFile;
private String _sinkDir;
private String _conOptions;
private final I2PAppContext _context;
private final Log _log;
private final String _samHost;
private final String _samPort;
private final String _destFile;
private final String _sinkDir;
private final String _conOptions;
private Socket _samSocket;
private OutputStream _samOut;
private InputStream _samIn;
private SAMReader _reader;
//private boolean _dead;
private SAMEventHandler _eventHandler;
private final SAMEventHandler _eventHandler;
/** Connection id (Integer) to peer (Flooder) */
private Map<Integer, Sink> _remotePeers;
private final Map<Integer, Sink> _remotePeers;
public static void main(String args[]) {
if (args.length < 4) {
@ -200,12 +200,12 @@ public class SAMStreamSink {
}
private class Sink {
private int _connectionId;
private String _remoteDestination;
private boolean _closed;
private long _started;
private final int _connectionId;
private final String _remoteDestination;
private volatile boolean _closed;
private final long _started;
private long _lastReceivedOn;
private OutputStream _out;
private final OutputStream _out;
public Sink(int conId, String remDest) throws IOException {
_connectionId = conId;
@ -222,6 +222,7 @@ public class SAMStreamSink {
File out = File.createTempFile("sink", ".dat", sinkDir);
_out = new FileOutputStream(out);
_started = _context.clock().now();
}
public int getConnectionId() { return _connectionId; }