java.lang.Object
net.i2p.util.EventDispatcherImpl
net.i2p.i2ptunnel.I2PTunnelTask
net.i2p.i2ptunnel.udpTunnel.I2PTunnelUDPServerBase
net.i2p.i2ptunnel.streamr.StreamrProducer
- All Implemented Interfaces:
Sink, Source, EventDispatcher
Streamr producer that acts as an I2P server and UDP client, receiving UDP data on a configured port and forwarding it through I2P.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MultiSourceHands the incoming feed to this tunnel's listeners.private final UDPSourceThe UDP socket the feed arrives on.Fields inherited from class I2PTunnelUDPServerBase
l, readTimeout, slockConstructor Summary
ConstructorsConstructorDescriptionStreamrProducer(int port, File privkey, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Creates a Streamr producer that receives UDP data and forwards it through I2P.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanclose(boolean forced) Stops the server and releases resources.final voidStarts the UDP server and begins forwarding data.Methods inherited from class I2PTunnelUDPServerBase
getReadTimeout, send, setReadTimeout, setSink, startModifier and TypeMethodDescriptionlongRead idle timeout for newly-created connections (in milliseconds).voidsend(Destination to, int fromPort, int toPort, byte[] data) Sends data through the I2P sink.voidsetReadTimeout(long ms) Sets the read idle timeout for newly-created connections (in milliseconds).voidSets the receiver of the UDP datagrams from I2P.voidstart()Starts the I2P source to begin receiving datagrams.Methods inherited from class I2PTunnelTask
connected, destroy, disconnected, errorOccurred, getBooleanOption, getId, getSocketManager, getTunnel, isOpen, optionsUpdated, reportAbuse, routerDisconnected, setId, setName, setTunnel, toStringModifier and TypeMethodDescriptionvoidconnected(I2PSession session) For tasks that don't callI2PTunnel.addSession(I2PSession)directly.booleandestroy()Note that the tunnel cannot be reopened after this by calling startRunning(), as it may destroy the underlying socket manager, depending on implementation.voiddisconnected(I2PSession session) Called when a session is disconnected.voiderrorOccurred(I2PSession session, String message, Throwable error) Does nothing here.protected booleangetBooleanOption(String opt, boolean dflt) Read a boolean client option from the tunnel's properties.intgetId()The id of the client list entry for this task.Returns the I2PSocketManager for this task, or null if not applicable.The I2PTunnel this task runs inside.booleanisOpen()Whether the tunnel is running and accepting connections.voidoptionsUpdated(I2PTunnel tunnel) Notify the task that I2PTunnel's options have been updated.voidreportAbuse(I2PSession session, int severity) Does nothing here.protected voidTell the tunnel that the router connection has dropped.voidsetId(int id) Record the client list entry id for this task.protected voidRecord the display name for this task.voidRebind this task to a different tunnel.toString()The display name given to this task when it was constructed.Methods inherited from class EventDispatcherImpl
attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, notifyEvent, unIgnoreEvents, waitEventValueModifier and TypeMethodDescriptionvoidAttach an EventDispatcher object to the events dispatching chain.voidDetach the specified EventDispatcher object from the events dispatching chain.Object to be used to deliver events (usuallythis, but YMMV).Retrieve the names of all the events that have been received.getEventValue(String name) Retrieve the value currently associated with the specified event value.voidIgnore further event notifications.voidnotifyEvent(String eventName, Object args) Deliver an event.voidAlmost like the method above :-).waitEventValue(String name) Wait until the given event has received a value.
Field Details
multi
Hands the incoming feed to this tunnel's listeners.server
The UDP socket the feed arrives on.
Constructor Details
StreamrProducer
public StreamrProducer(int port, File privkey, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Creates a Streamr producer that receives UDP data and forwards it through I2P.- Parameters:
port- local UDP port to listen onprivkey- I2P private key file for the destinationprivkeyname- name of the private keyl- the logging facility passed on to the superclassnotifyThis- event dispatcher for notificationstunnel- the owning I2PTunnel, which supplies the client options and context
Method Details
startRunning
public final void startRunning()Starts the UDP server and begins forwarding data.- Overrides:
startRunningin classI2PTunnelUDPServerBase
close
public boolean close(boolean forced) Stops the server and releases resources.- Overrides:
closein classI2PTunnelUDPServerBase- Parameters:
forced- if true, forces immediate close- Returns:
- true if closed successfully