java.lang.Object
net.i2p.sam.client.SAMStreamSend.Sender
- All Implemented Interfaces:
Runnable
- Enclosing class:
SAMStreamSend
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether the session has been closed.private final StringThe SAM connection id.private final InetSocketAddressBridge address for datagram sends.private final DatagramSocketDatagram socket for datagram modes.private final SAMEventHandlerHandler for this session's events.private InputStreamStream the data is read from.private final intThe send mode to run.private StringThe destination being sent to.private final OutputStreamStream for sending through this session.private longWhen the session opened.private longTotal bytes sent so far.Constructor Summary
ConstructorsConstructorDescriptionSender(OutputStream samOut, SAMEventHandler eventHandler, int mode) Registers a sender with the stream, opening a datagram socket for datagram modes.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidclosed()Closes the stream once and records its lifetime in the statistics.SAM connection id.Remote destination of the stream.booleanReads the destination key from disk and issues STREAM CONNECT.voidrun()Sends the data file over the stream in chunks until it ends or closes.
Field Details
_connectionId
The SAM connection id._remoteDestination
The destination being sent to._in
Stream the data is read from._closed
private volatile boolean _closedWhether the session has been closed._started
private long _startedWhen the session opened._totalSent
private long _totalSentTotal bytes sent so far._samOut
Stream for sending through this session._eventHandler
Handler for this session's events._mode
private final int _modeThe send mode to run._dgSock
Datagram socket for datagram modes._dgSAM
Bridge address for datagram sends.
Constructor Details
Sender
Registers a sender with the stream, opening a datagram socket for datagram modes.- Parameters:
samOut- the SAM output stream for stream modes, null for datagram modeseventHandler- the handler tracking events for this streammode- the SAM mode, stream, datagram or raw- Throws:
IOException- if the datagram socket cannot be opened
Method Details
openConnection
public boolean openConnection()Reads the destination key from disk and issues STREAM CONNECT.- Returns:
- true if the bridge reported the stream connected, false on any error
getConnectionId
getDestination
Remote destination of the stream.- Returns:
- the remote destination read from the dest file, or null before the connection is opened
closed
public void closed()Closes the stream once and records its lifetime in the statistics.run