java.lang.Object
net.i2p.util.EventDispatcherImpl
net.i2p.i2ptunnel.I2PTunnelTask
net.i2p.i2ptunnel.udpTunnel.I2PTunnelUDPClientBase
net.i2p.i2ptunnel.streamr.StreamrConsumer
- All Implemented Interfaces:
Sink, Source, EventDispatcher
Streamr consumer that acts as an I2P client and UDP server, receiving data from I2P destinations and forwarding it to a configured UDP host/port.
Field Summary
FieldsFields inherited from class I2PTunnelUDPClientBase
_clientId, _context, lModifier and TypeFieldDescriptionprotected longUnique client identifier.protected I2PAppContextThe I2P app context.protected LoggingLogging instance.Constructor Summary
ConstructorsConstructorDescriptionStreamrConsumer(InetAddress host, int port, String destination, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Creates a Streamr consumer that receives data from I2P and forwards it to a UDP destination.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanclose(boolean forced) Stops the consumer and releases resources.final voidStarts the consumer and begins receiving data.Methods inherited from class I2PTunnelUDPClientBase
send, setSink, startModifier and TypeMethodDescriptionvoidsend(Destination to, int fromPort, int toPort, byte[] data) Sends data through the I2P sink to the configured destination.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
sink
Where received messages are delivered.pinger
Sends the keep-alive pings.
Constructor Details
StreamrConsumer
public StreamrConsumer(InetAddress host, int port, String destination, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Creates a Streamr consumer that receives data from I2P and forwards it to a UDP destination.- Parameters:
host- UDP destination hostnameport- UDP destination portdestination- I2P destination to subscribe tol- the Logging instance this tunnel's status messages are sent tonotifyThis- event dispatcher for notificationstunnel- the parent tunnel, supplying the context and I2CP options
Method Details
startRunning
public final void startRunning()Starts the consumer and begins receiving data.- Overrides:
startRunningin classI2PTunnelUDPClientBase
close
public boolean close(boolean forced) Stops the consumer and releases resources.- Overrides:
closein classI2PTunnelUDPClientBase- Parameters:
forced- if true, forces immediate close- Returns:
- true if closed successfully